GeneratorConfig.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Intl\Data\Generator;
  11. use Symfony\Component\Intl\Data\Bundle\Writer\BundleWriterInterface;
  12. /**
  13. * Stores contextual information for resource bundle generation.
  14. *
  15. * @author Bernhard Schussek <bschussek@gmail.com>
  16. *
  17. * @internal
  18. */
  19. class GeneratorConfig
  20. {
  21. private $sourceDir;
  22. private $icuVersion;
  23. /**
  24. * @var BundleWriterInterface[]
  25. */
  26. private $bundleWriters = [];
  27. public function __construct(string $sourceDir, string $icuVersion)
  28. {
  29. $this->sourceDir = $sourceDir;
  30. $this->icuVersion = $icuVersion;
  31. }
  32. /**
  33. * Adds a writer to be used during the data conversion.
  34. */
  35. public function addBundleWriter(string $targetDir, BundleWriterInterface $writer)
  36. {
  37. $this->bundleWriters[$targetDir] = $writer;
  38. }
  39. /**
  40. * Returns the writers indexed by their output directories.
  41. *
  42. * @return BundleWriterInterface[]
  43. */
  44. public function getBundleWriters(): array
  45. {
  46. return $this->bundleWriters;
  47. }
  48. /**
  49. * Returns the directory where the source versions of the resource bundles
  50. * are stored.
  51. *
  52. * @return string An absolute path to a directory
  53. */
  54. public function getSourceDir(): string
  55. {
  56. return $this->sourceDir;
  57. }
  58. /**
  59. * Returns the ICU version of the bundles being converted.
  60. *
  61. * @return string The ICU version string
  62. */
  63. public function getIcuVersion(): string
  64. {
  65. return $this->icuVersion;
  66. }
  67. }