Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 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 | |
| 12 | namespace Symfony\Component\Translation\Extractor; |
| 13 | |
| 14 | use Symfony\Component\Translation\MessageCatalogue; |
| 15 | |
| 16 | /** |
| 17 | * ChainExtractor extracts translation messages from template files. |
| 18 | * |
| 19 | * @author Michel Salib <michelsalib@hotmail.com> |
| 20 | */ |
| 21 | class ChainExtractor implements ExtractorInterface |
| 22 | { |
| 23 | /** |
| 24 | * The extractors. |
| 25 | * |
| 26 | * @var ExtractorInterface[] |
| 27 | */ |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame^] | 28 | private array $extractors = []; |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 29 | |
| 30 | /** |
| 31 | * Adds a loader to the translation extractor. |
| 32 | */ |
| 33 | public function addExtractor(string $format, ExtractorInterface $extractor) |
| 34 | { |
| 35 | $this->extractors[$format] = $extractor; |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * {@inheritdoc} |
| 40 | */ |
| 41 | public function setPrefix(string $prefix) |
| 42 | { |
| 43 | foreach ($this->extractors as $extractor) { |
| 44 | $extractor->setPrefix($prefix); |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * {@inheritdoc} |
| 50 | */ |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame^] | 51 | public function extract(string|iterable $directory, MessageCatalogue $catalogue) |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 52 | { |
| 53 | foreach ($this->extractors as $extractor) { |
| 54 | $extractor->extract($directory, $catalogue); |
| 55 | } |
| 56 | } |
| 57 | } |