Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/translation/DependencyInjection/TranslatorPass.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 1fec387a4317 |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
9 * file that was distributed with this source code. | 9 * file that was distributed with this source code. |
10 */ | 10 */ |
11 | 11 |
12 namespace Symfony\Component\Translation\DependencyInjection; | 12 namespace Symfony\Component\Translation\DependencyInjection; |
13 | 13 |
14 use Symfony\Component\DependencyInjection\Reference; | |
15 use Symfony\Component\DependencyInjection\ContainerBuilder; | |
16 use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | 14 use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
17 use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass; | 15 use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass; |
16 use Symfony\Component\DependencyInjection\ContainerBuilder; | |
17 use Symfony\Component\DependencyInjection\Reference; | |
18 | 18 |
19 class TranslatorPass implements CompilerPassInterface | 19 class TranslatorPass implements CompilerPassInterface |
20 { | 20 { |
21 private $translatorServiceId; | 21 private $translatorServiceId; |
22 private $readerServiceId; | 22 private $readerServiceId; |
24 private $debugCommandServiceId; | 24 private $debugCommandServiceId; |
25 private $updateCommandServiceId; | 25 private $updateCommandServiceId; |
26 | 26 |
27 public function __construct($translatorServiceId = 'translator.default', $readerServiceId = 'translation.loader', $loaderTag = 'translation.loader', $debugCommandServiceId = 'console.command.translation_debug', $updateCommandServiceId = 'console.command.translation_update') | 27 public function __construct($translatorServiceId = 'translator.default', $readerServiceId = 'translation.loader', $loaderTag = 'translation.loader', $debugCommandServiceId = 'console.command.translation_debug', $updateCommandServiceId = 'console.command.translation_update') |
28 { | 28 { |
29 if ('translation.loader' === $readerServiceId && 2 > func_num_args()) { | 29 if ('translation.loader' === $readerServiceId && 2 > \func_num_args()) { |
30 @trigger_error('The default value for $readerServiceId will change in 4.0 to "translation.reader".', E_USER_DEPRECATED); | 30 @trigger_error(sprintf('The default value for $readerServiceId in "%s()" will change in 4.0 to "translation.reader".', __METHOD__), E_USER_DEPRECATED); |
31 } | 31 } |
32 | 32 |
33 $this->translatorServiceId = $translatorServiceId; | 33 $this->translatorServiceId = $translatorServiceId; |
34 $this->readerServiceId = $readerServiceId; | 34 $this->readerServiceId = $readerServiceId; |
35 $this->loaderTag = $loaderTag; | 35 $this->loaderTag = $loaderTag; |
41 { | 41 { |
42 if (!$container->hasDefinition($this->translatorServiceId)) { | 42 if (!$container->hasDefinition($this->translatorServiceId)) { |
43 return; | 43 return; |
44 } | 44 } |
45 | 45 |
46 $loaders = array(); | 46 $loaders = []; |
47 $loaderRefs = array(); | 47 $loaderRefs = []; |
48 foreach ($container->findTaggedServiceIds($this->loaderTag, true) as $id => $attributes) { | 48 foreach ($container->findTaggedServiceIds($this->loaderTag, true) as $id => $attributes) { |
49 $loaderRefs[$id] = new Reference($id); | 49 $loaderRefs[$id] = new Reference($id); |
50 $loaders[$id][] = $attributes[0]['alias']; | 50 $loaders[$id][] = $attributes[0]['alias']; |
51 if (isset($attributes[0]['legacy-alias'])) { | 51 if (isset($attributes[0]['legacy-alias'])) { |
52 $loaders[$id][] = $attributes[0]['legacy-alias']; | 52 $loaders[$id][] = $attributes[0]['legacy-alias']; |
55 | 55 |
56 if ($container->hasDefinition($this->readerServiceId)) { | 56 if ($container->hasDefinition($this->readerServiceId)) { |
57 $definition = $container->getDefinition($this->readerServiceId); | 57 $definition = $container->getDefinition($this->readerServiceId); |
58 foreach ($loaders as $id => $formats) { | 58 foreach ($loaders as $id => $formats) { |
59 foreach ($formats as $format) { | 59 foreach ($formats as $format) { |
60 $definition->addMethodCall('addLoader', array($format, $loaderRefs[$id])); | 60 $definition->addMethodCall('addLoader', [$format, $loaderRefs[$id]]); |
61 } | 61 } |
62 } | 62 } |
63 } | 63 } |
64 | 64 |
65 // Duplicated code to support "translation.reader", to be removed in 4.0 | 65 // Duplicated code to support "translation.reader", to be removed in 4.0 |
66 if ('translation.reader' !== $this->readerServiceId) { | 66 if ('translation.reader' !== $this->readerServiceId) { |
67 if ($container->hasDefinition('translation.reader')) { | 67 if ($container->hasDefinition('translation.reader')) { |
68 $definition = $container->getDefinition('translation.reader'); | 68 $definition = $container->getDefinition('translation.reader'); |
69 foreach ($loaders as $id => $formats) { | 69 foreach ($loaders as $id => $formats) { |
70 foreach ($formats as $format) { | 70 foreach ($formats as $format) { |
71 $definition->addMethodCall('addLoader', array($format, $loaderRefs[$id])); | 71 $definition->addMethodCall('addLoader', [$format, $loaderRefs[$id]]); |
72 } | 72 } |
73 } | 73 } |
74 } | 74 } |
75 } | 75 } |
76 | 76 |