Mercurial > hg > cmmr2012-drupal-site
comparison vendor/symfony/translation/DependencyInjection/TranslationExtractorPass.php @ 0:c75dbcec494b
Initial commit from drush-created site
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2018 14:24:15 +0000 |
parents | |
children | a9cd425dd02b |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c75dbcec494b |
---|---|
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\DependencyInjection; | |
13 | |
14 use Symfony\Component\DependencyInjection\Reference; | |
15 use Symfony\Component\DependencyInjection\ContainerBuilder; | |
16 use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | |
17 use Symfony\Component\DependencyInjection\Exception\RuntimeException; | |
18 | |
19 /** | |
20 * Adds tagged translation.extractor services to translation extractor. | |
21 */ | |
22 class TranslationExtractorPass implements CompilerPassInterface | |
23 { | |
24 private $extractorServiceId; | |
25 private $extractorTag; | |
26 | |
27 public function __construct($extractorServiceId = 'translation.extractor', $extractorTag = 'translation.extractor') | |
28 { | |
29 $this->extractorServiceId = $extractorServiceId; | |
30 $this->extractorTag = $extractorTag; | |
31 } | |
32 | |
33 public function process(ContainerBuilder $container) | |
34 { | |
35 if (!$container->hasDefinition($this->extractorServiceId)) { | |
36 return; | |
37 } | |
38 | |
39 $definition = $container->getDefinition($this->extractorServiceId); | |
40 | |
41 foreach ($container->findTaggedServiceIds($this->extractorTag, true) as $id => $attributes) { | |
42 if (!isset($attributes[0]['alias'])) { | |
43 throw new RuntimeException(sprintf('The alias for the tag "translation.extractor" of service "%s" must be set.', $id)); | |
44 } | |
45 | |
46 $definition->addMethodCall('addExtractor', array($attributes[0]['alias'], new Reference($id))); | |
47 } | |
48 } | |
49 } |