Нема описа

ChainExtractor.php 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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\Translation\Extractor;
  11. use Symfony\Component\Translation\MessageCatalogue;
  12. /**
  13. * ChainExtractor extracts translation messages from template files.
  14. *
  15. * @author Michel Salib <michelsalib@hotmail.com>
  16. */
  17. class ChainExtractor implements ExtractorInterface
  18. {
  19. /**
  20. * The extractors.
  21. *
  22. * @var ExtractorInterface[]
  23. */
  24. private $extractors = [];
  25. /**
  26. * Adds a loader to the translation extractor.
  27. *
  28. * @param string $format The format of the loader
  29. */
  30. public function addExtractor($format, ExtractorInterface $extractor)
  31. {
  32. $this->extractors[$format] = $extractor;
  33. }
  34. /**
  35. * {@inheritdoc}
  36. */
  37. public function setPrefix($prefix)
  38. {
  39. foreach ($this->extractors as $extractor) {
  40. $extractor->setPrefix($prefix);
  41. }
  42. }
  43. /**
  44. * {@inheritdoc}
  45. */
  46. public function extract($directory, MessageCatalogue $catalogue)
  47. {
  48. foreach ($this->extractors as $extractor) {
  49. $extractor->extract($directory, $catalogue);
  50. }
  51. }
  52. }