annotate vendor/symfony/translation/DependencyInjection/TranslationExtractorPass.php @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents a9cd425dd02b
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 /*
Chris@0 4 * This file is part of the Symfony package.
Chris@0 5 *
Chris@0 6 * (c) Fabien Potencier <fabien@symfony.com>
Chris@0 7 *
Chris@0 8 * For the full copyright and license information, please view the LICENSE
Chris@0 9 * file that was distributed with this source code.
Chris@0 10 */
Chris@0 11
Chris@0 12 namespace Symfony\Component\Translation\DependencyInjection;
Chris@0 13
Chris@4 14 use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
Chris@4 15 use Symfony\Component\DependencyInjection\ContainerBuilder;
Chris@4 16 use Symfony\Component\DependencyInjection\Exception\RuntimeException;
Chris@0 17 use Symfony\Component\DependencyInjection\Reference;
Chris@0 18
Chris@0 19 /**
Chris@0 20 * Adds tagged translation.extractor services to translation extractor.
Chris@0 21 */
Chris@0 22 class TranslationExtractorPass implements CompilerPassInterface
Chris@0 23 {
Chris@0 24 private $extractorServiceId;
Chris@0 25 private $extractorTag;
Chris@0 26
Chris@0 27 public function __construct($extractorServiceId = 'translation.extractor', $extractorTag = 'translation.extractor')
Chris@0 28 {
Chris@0 29 $this->extractorServiceId = $extractorServiceId;
Chris@0 30 $this->extractorTag = $extractorTag;
Chris@0 31 }
Chris@0 32
Chris@0 33 public function process(ContainerBuilder $container)
Chris@0 34 {
Chris@0 35 if (!$container->hasDefinition($this->extractorServiceId)) {
Chris@0 36 return;
Chris@0 37 }
Chris@0 38
Chris@0 39 $definition = $container->getDefinition($this->extractorServiceId);
Chris@0 40
Chris@0 41 foreach ($container->findTaggedServiceIds($this->extractorTag, true) as $id => $attributes) {
Chris@0 42 if (!isset($attributes[0]['alias'])) {
Chris@0 43 throw new RuntimeException(sprintf('The alias for the tag "translation.extractor" of service "%s" must be set.', $id));
Chris@0 44 }
Chris@0 45
Chris@4 46 $definition->addMethodCall('addExtractor', [$attributes[0]['alias'], new Reference($id)]);
Chris@0 47 }
Chris@0 48 }
Chris@0 49 }