AbstractFileExtractor.php
1 month ago
ChainExtractor.php
1 month ago
ExtractorInterface.php
1 month ago
PhpExtractor.php
1 month ago
PhpStringTokenParser.php
1 month ago
ChainExtractor.php
54 lines
| 1 | <?php |
| 2 | |
| 3 | /* |
| 4 | * This file is part of the Symfony package. |
| 5 | * |
| 6 | * (c) Fabien Potencier <fabien@symfony.com> |
| 7 | * |
| 8 | * For the full copyright and license information, please view the LICENSE |
| 9 | * file that was distributed with this source code. |
| 10 | */ |
| 11 | namespace IAWPSCOPED\Symfony\Component\Translation\Extractor; |
| 12 | |
| 13 | use IAWPSCOPED\Symfony\Component\Translation\MessageCatalogue; |
| 14 | /** |
| 15 | * ChainExtractor extracts translation messages from template files. |
| 16 | * |
| 17 | * @author Michel Salib <michelsalib@hotmail.com> |
| 18 | * @internal |
| 19 | */ |
| 20 | class ChainExtractor implements ExtractorInterface |
| 21 | { |
| 22 | /** |
| 23 | * The extractors. |
| 24 | * |
| 25 | * @var ExtractorInterface[] |
| 26 | */ |
| 27 | private array $extractors = []; |
| 28 | /** |
| 29 | * Adds a loader to the translation extractor. |
| 30 | */ |
| 31 | public function addExtractor(string $format, ExtractorInterface $extractor) |
| 32 | { |
| 33 | $this->extractors[$format] = $extractor; |
| 34 | } |
| 35 | /** |
| 36 | * {@inheritdoc} |
| 37 | */ |
| 38 | public function setPrefix(string $prefix) |
| 39 | { |
| 40 | foreach ($this->extractors as $extractor) { |
| 41 | $extractor->setPrefix($prefix); |
| 42 | } |
| 43 | } |
| 44 | /** |
| 45 | * {@inheritdoc} |
| 46 | */ |
| 47 | public function extract(string|iterable $directory, MessageCatalogue $catalogue) |
| 48 | { |
| 49 | foreach ($this->extractors as $extractor) { |
| 50 | $extractor->extract($directory, $catalogue); |
| 51 | } |
| 52 | } |
| 53 | } |
| 54 |