|
14 | 14 | use Doctrine\Common\Annotations\Reader;
|
15 | 15 | use Symfony\Bridge\Monolog\Processor\DebugProcessor;
|
16 | 16 | use Symfony\Component\Cache\Adapter\AdapterInterface;
|
| 17 | +use Symfony\Component\Config\Loader\LoaderInterface; |
17 | 18 | use Symfony\Component\DependencyInjection\Alias;
|
18 | 19 | use Symfony\Component\DependencyInjection\ChildDefinition;
|
19 | 20 | use Symfony\Component\DependencyInjection\ContainerBuilder;
|
@@ -85,14 +86,22 @@ public function load(array $configs, ContainerBuilder $container)
|
85 | 86 | $this->annotationsConfigEnabled = $this->isConfigEnabled($container, $config['annotations']);
|
86 | 87 |
|
87 | 88 | // A translator must always be registered (as support is included by
|
88 |
| - // default in the Form component). If disabled, an identity translator |
89 |
| - // will be used and everything will still work as expected. |
90 |
| - if (class_exists('Symfony\Component\Translation\Translator') || $this->isConfigEnabled($container, $config['form'])) { |
91 |
| - if (!class_exists('Symfony\Component\Translation\Translator')) { |
| 89 | + // default in the Form and Validator component). If disabled, an identity |
| 90 | + // translator will be used and everything will still work as expected. |
| 91 | + if ($this->isConfigEnabled($container, $config['translator']) || $this->isConfigEnabled($container, $config['form']) || $this->isConfigEnabled($container, $config['validation'])) { |
| 92 | + if (!class_exists('Symfony\Component\Translation\Translator') && $this->isConfigEnabled($container, $config['translator'])) { |
| 93 | + throw new LogicException('Translation support cannot be enabled as the Translation component is not installed.'); |
| 94 | + } |
| 95 | + |
| 96 | + if (!class_exists('Symfony\Component\Translation\Translator') && $this->isConfigEnabled($container, $config['form'])) { |
92 | 97 | throw new LogicException('Form support cannot be enabled as the Translation component is not installed.');
|
93 | 98 | }
|
94 | 99 |
|
95 |
| - $loader->load('translation.xml'); |
| 100 | + if (!class_exists('Symfony\Component\Translation\Translator') && $this->isConfigEnabled($container, $config['validation'])) { |
| 101 | + throw new LogicException('Validation support cannot be enabled as the Translation component is not installed.'); |
| 102 | + } |
| 103 | + |
| 104 | + $loader->load('identity_translator.xml'); |
96 | 105 | }
|
97 | 106 |
|
98 | 107 | if (isset($config['secret'])) {
|
@@ -165,7 +174,7 @@ public function load(array $configs, ContainerBuilder $container)
|
165 | 174 | $this->registerEsiConfiguration($config['esi'], $container, $loader);
|
166 | 175 | $this->registerSsiConfiguration($config['ssi'], $container, $loader);
|
167 | 176 | $this->registerFragmentsConfiguration($config['fragments'], $container, $loader);
|
168 |
| - $this->registerTranslatorConfiguration($config['translator'], $container); |
| 177 | + $this->registerTranslatorConfiguration($config['translator'], $container, $loader); |
169 | 178 | $this->registerProfilerConfiguration($config['profiler'], $container, $loader);
|
170 | 179 | $this->registerCacheConfiguration($config['cache'], $container);
|
171 | 180 | $this->registerWorkflowConfiguration($config['workflows'], $container, $loader);
|
@@ -802,15 +811,13 @@ private function createVersion(ContainerBuilder $container, $version, $format, $
|
802 | 811 | * @param array $config A translator configuration array
|
803 | 812 | * @param ContainerBuilder $container A ContainerBuilder instance
|
804 | 813 | */
|
805 |
| - private function registerTranslatorConfiguration(array $config, ContainerBuilder $container) |
| 814 | + private function registerTranslatorConfiguration(array $config, ContainerBuilder $container, LoaderInterface $loader) |
806 | 815 | {
|
807 | 816 | if (!$this->isConfigEnabled($container, $config)) {
|
808 | 817 | return;
|
809 | 818 | }
|
810 | 819 |
|
811 |
| - if (!class_exists('Symfony\Component\Translation\Translator')) { |
812 |
| - throw new LogicException('Translation support cannot be enabled as the Translator component is not installed.'); |
813 |
| - } |
| 820 | + $loader->load('translation.xml'); |
814 | 821 |
|
815 | 822 | $this->translationConfigEnabled = true;
|
816 | 823 |
|
|
0 commit comments