You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.3 KiB

3 years ago
  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(string $format, ExtractorInterface $extractor)
  31. {
  32. $this->extractors[$format] = $extractor;
  33. }
  34. /**
  35. * {@inheritdoc}
  36. */
  37. public function setPrefix(string $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. }