菜谱项目

ChainExtractor.php 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 = array();
  25. /**
  26. * Adds a loader to the translation extractor.
  27. *
  28. * @param string $format The format of the loader
  29. * @param ExtractorInterface $extractor The loader
  30. */
  31. public function addExtractor($format, ExtractorInterface $extractor)
  32. {
  33. $this->extractors[$format] = $extractor;
  34. }
  35. /**
  36. * {@inheritdoc}
  37. */
  38. public function setPrefix($prefix)
  39. {
  40. foreach ($this->extractors as $extractor) {
  41. $extractor->setPrefix($prefix);
  42. }
  43. }
  44. /**
  45. * {@inheritdoc}
  46. */
  47. public function extract($directory, MessageCatalogue $catalogue)
  48. {
  49. foreach ($this->extractors as $extractor) {
  50. $extractor->extract($directory, $catalogue);
  51. }
  52. }
  53. }