wp-user-avatar
/
third-party
/
vendor
/
symfony
/
translation
/
DependencyInjection
/
TranslationExtractorPass.php
wp-user-avatar
/
third-party
/
vendor
/
symfony
/
translation
/
DependencyInjection
Last commit date
TranslationDumperPass.php
2 months ago
TranslationExtractorPass.php
2 months ago
TranslatorPass.php
2 months ago
TranslatorPathsPass.php
2 months ago
TranslationExtractorPass.php
46 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 ProfilePressVendor\Symfony\Component\Translation\DependencyInjection; |
| 12 | |
| 13 | use ProfilePressVendor\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
| 14 | use ProfilePressVendor\Symfony\Component\DependencyInjection\ContainerBuilder; |
| 15 | use ProfilePressVendor\Symfony\Component\DependencyInjection\Exception\RuntimeException; |
| 16 | use ProfilePressVendor\Symfony\Component\DependencyInjection\Reference; |
| 17 | /** |
| 18 | * Adds tagged translation.extractor services to translation extractor. |
| 19 | */ |
| 20 | class TranslationExtractorPass implements CompilerPassInterface |
| 21 | { |
| 22 | private $extractorServiceId; |
| 23 | private $extractorTag; |
| 24 | public function __construct(string $extractorServiceId = 'translation.extractor', string $extractorTag = 'translation.extractor') |
| 25 | { |
| 26 | if (0 < \func_num_args()) { |
| 27 | trigger_deprecation('symfony/translation', '5.3', 'Configuring "%s" is deprecated.', __CLASS__); |
| 28 | } |
| 29 | $this->extractorServiceId = $extractorServiceId; |
| 30 | $this->extractorTag = $extractorTag; |
| 31 | } |
| 32 | public function process(ContainerBuilder $container) |
| 33 | { |
| 34 | if (!$container->hasDefinition($this->extractorServiceId)) { |
| 35 | return; |
| 36 | } |
| 37 | $definition = $container->getDefinition($this->extractorServiceId); |
| 38 | foreach ($container->findTaggedServiceIds($this->extractorTag, \true) as $id => $attributes) { |
| 39 | if (!isset($attributes[0]['alias'])) { |
| 40 | throw new RuntimeException(sprintf('The alias for the tag "translation.extractor" of service "%s" must be set.', $id)); |
| 41 | } |
| 42 | $definition->addMethodCall('addExtractor', [$attributes[0]['alias'], new Reference($id)]); |
| 43 | } |
| 44 | } |
| 45 | } |
| 46 |