1 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,89 +0,0 @@ |
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\Compiler\CompilerPassInterface; |
|
15 |
-use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass; |
|
16 |
-use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
17 |
-use Symfony\Component\DependencyInjection\Reference; |
|
18 |
- |
|
19 |
-class TranslatorPass implements CompilerPassInterface |
|
20 |
-{ |
|
21 |
- private $translatorServiceId; |
|
22 |
- private $readerServiceId; |
|
23 |
- private $loaderTag; |
|
24 |
- private $debugCommandServiceId; |
|
25 |
- private $updateCommandServiceId; |
|
26 |
- |
|
27 |
- public function __construct(string $translatorServiceId = 'translator.default', string $readerServiceId = 'translation.reader', string $loaderTag = 'translation.loader', string $debugCommandServiceId = 'console.command.translation_debug', string $updateCommandServiceId = 'console.command.translation_update') |
|
28 |
- { |
|
29 |
- $this->translatorServiceId = $translatorServiceId; |
|
30 |
- $this->readerServiceId = $readerServiceId; |
|
31 |
- $this->loaderTag = $loaderTag; |
|
32 |
- $this->debugCommandServiceId = $debugCommandServiceId; |
|
33 |
- $this->updateCommandServiceId = $updateCommandServiceId; |
|
34 |
- } |
|
35 |
- |
|
36 |
- public function process(ContainerBuilder $container) |
|
37 |
- { |
|
38 |
- if (!$container->hasDefinition($this->translatorServiceId)) { |
|
39 |
- return; |
|
40 |
- } |
|
41 |
- |
|
42 |
- $loaders = []; |
|
43 |
- $loaderRefs = []; |
|
44 |
- foreach ($container->findTaggedServiceIds($this->loaderTag, true) as $id => $attributes) { |
|
45 |
- $loaderRefs[$id] = new Reference($id); |
|
46 |
- $loaders[$id][] = $attributes[0]['alias']; |
|
47 |
- if (isset($attributes[0]['legacy-alias'])) { |
|
48 |
- $loaders[$id][] = $attributes[0]['legacy-alias']; |
|
49 |
- } |
|
50 |
- } |
|
51 |
- |
|
52 |
- if ($container->hasDefinition($this->readerServiceId)) { |
|
53 |
- $definition = $container->getDefinition($this->readerServiceId); |
|
54 |
- foreach ($loaders as $id => $formats) { |
|
55 |
- foreach ($formats as $format) { |
|
56 |
- $definition->addMethodCall('addLoader', [$format, $loaderRefs[$id]]); |
|
57 |
- } |
|
58 |
- } |
|
59 |
- } |
|
60 |
- |
|
61 |
- $container |
|
62 |
- ->findDefinition($this->translatorServiceId) |
|
63 |
- ->replaceArgument(0, ServiceLocatorTagPass::register($container, $loaderRefs)) |
|
64 |
- ->replaceArgument(3, $loaders) |
|
65 |
- ; |
|
66 |
- |
|
67 |
- if (!$container->hasParameter('twig.default_path')) { |
|
68 |
- return; |
|
69 |
- } |
|
70 |
- |
|
71 |
- $paths = array_keys($container->getDefinition('twig.template_iterator')->getArgument(2)); |
|
72 |
- if ($container->hasDefinition($this->debugCommandServiceId)) { |
|
73 |
- $definition = $container->getDefinition($this->debugCommandServiceId); |
|
74 |
- $definition->replaceArgument(4, $container->getParameter('twig.default_path')); |
|
75 |
- |
|
76 |
- if (\count($definition->getArguments()) > 6) { |
|
77 |
- $definition->replaceArgument(6, $paths); |
|
78 |
- } |
|
79 |
- } |
|
80 |
- if ($container->hasDefinition($this->updateCommandServiceId)) { |
|
81 |
- $definition = $container->getDefinition($this->updateCommandServiceId); |
|
82 |
- $definition->replaceArgument(5, $container->getParameter('twig.default_path')); |
|
83 |
- |
|
84 |
- if (\count($definition->getArguments()) > 7) { |
|
85 |
- $definition->replaceArgument(7, $paths); |
|
86 |
- } |
|
87 |
- } |
|
88 |
- } |
|
89 |
-} |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,89 @@ |
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\Compiler\CompilerPassInterface; |
|
15 |
+use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass; |
|
16 |
+use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
17 |
+use Symfony\Component\DependencyInjection\Reference; |
|
18 |
+ |
|
19 |
+class TranslatorPass implements CompilerPassInterface |
|
20 |
+{ |
|
21 |
+ private $translatorServiceId; |
|
22 |
+ private $readerServiceId; |
|
23 |
+ private $loaderTag; |
|
24 |
+ private $debugCommandServiceId; |
|
25 |
+ private $updateCommandServiceId; |
|
26 |
+ |
|
27 |
+ public function __construct(string $translatorServiceId = 'translator.default', string $readerServiceId = 'translation.reader', string $loaderTag = 'translation.loader', string $debugCommandServiceId = 'console.command.translation_debug', string $updateCommandServiceId = 'console.command.translation_update') |
|
28 |
+ { |
|
29 |
+ $this->translatorServiceId = $translatorServiceId; |
|
30 |
+ $this->readerServiceId = $readerServiceId; |
|
31 |
+ $this->loaderTag = $loaderTag; |
|
32 |
+ $this->debugCommandServiceId = $debugCommandServiceId; |
|
33 |
+ $this->updateCommandServiceId = $updateCommandServiceId; |
|
34 |
+ } |
|
35 |
+ |
|
36 |
+ public function process(ContainerBuilder $container) |
|
37 |
+ { |
|
38 |
+ if (!$container->hasDefinition($this->translatorServiceId)) { |
|
39 |
+ return; |
|
40 |
+ } |
|
41 |
+ |
|
42 |
+ $loaders = []; |
|
43 |
+ $loaderRefs = []; |
|
44 |
+ foreach ($container->findTaggedServiceIds($this->loaderTag, true) as $id => $attributes) { |
|
45 |
+ $loaderRefs[$id] = new Reference($id); |
|
46 |
+ $loaders[$id][] = $attributes[0]['alias']; |
|
47 |
+ if (isset($attributes[0]['legacy-alias'])) { |
|
48 |
+ $loaders[$id][] = $attributes[0]['legacy-alias']; |
|
49 |
+ } |
|
50 |
+ } |
|
51 |
+ |
|
52 |
+ if ($container->hasDefinition($this->readerServiceId)) { |
|
53 |
+ $definition = $container->getDefinition($this->readerServiceId); |
|
54 |
+ foreach ($loaders as $id => $formats) { |
|
55 |
+ foreach ($formats as $format) { |
|
56 |
+ $definition->addMethodCall('addLoader', [$format, $loaderRefs[$id]]); |
|
57 |
+ } |
|
58 |
+ } |
|
59 |
+ } |
|
60 |
+ |
|
61 |
+ $container |
|
62 |
+ ->findDefinition($this->translatorServiceId) |
|
63 |
+ ->replaceArgument(0, ServiceLocatorTagPass::register($container, $loaderRefs)) |
|
64 |
+ ->replaceArgument(3, $loaders) |
|
65 |
+ ; |
|
66 |
+ |
|
67 |
+ if (!$container->hasParameter('twig.default_path')) { |
|
68 |
+ return; |
|
69 |
+ } |
|
70 |
+ |
|
71 |
+ $paths = array_keys($container->getDefinition('twig.template_iterator')->getArgument(2)); |
|
72 |
+ if ($container->hasDefinition($this->debugCommandServiceId)) { |
|
73 |
+ $definition = $container->getDefinition($this->debugCommandServiceId); |
|
74 |
+ $definition->replaceArgument(4, $container->getParameter('twig.default_path')); |
|
75 |
+ |
|
76 |
+ if (\count($definition->getArguments()) > 6) { |
|
77 |
+ $definition->replaceArgument(6, $paths); |
|
78 |
+ } |
|
79 |
+ } |
|
80 |
+ if ($container->hasDefinition($this->updateCommandServiceId)) { |
|
81 |
+ $definition = $container->getDefinition($this->updateCommandServiceId); |
|
82 |
+ $definition->replaceArgument(5, $container->getParameter('twig.default_path')); |
|
83 |
+ |
|
84 |
+ if (\count($definition->getArguments()) > 7) { |
|
85 |
+ $definition->replaceArgument(7, $paths); |
|
86 |
+ } |
|
87 |
+ } |
|
88 |
+ } |
|
89 |
+} |