|
74 | 74 | use Symfony\Component\Serializer\Normalizer\NormalizerInterface; |
75 | 75 | use Symfony\Component\Stopwatch\Stopwatch; |
76 | 76 | use Symfony\Component\Translation\Command\XliffLintCommand as BaseXliffLintCommand; |
| 77 | +use Symfony\Component\Translation\Translator; |
77 | 78 | use Symfony\Component\Validator\ConstraintValidatorInterface; |
78 | 79 | use Symfony\Component\Validator\ObjectInitializerInterface; |
79 | 80 | use Symfony\Component\WebLink\HttpHeaderSerializer; |
@@ -189,15 +190,13 @@ public function load(array $configs, ContainerBuilder $container) |
189 | 190 | throw new LogicException('Translation support cannot be enabled as the Translation component is not installed.'); |
190 | 191 | } |
191 | 192 |
|
192 | | - if (!class_exists('Symfony\Component\Translation\Translator') && $this->isConfigEnabled($container, $config['form'])) { |
193 | | - throw new LogicException('Form support cannot be enabled as the Translation component is not installed.'); |
194 | | - } |
195 | | - |
196 | 193 | if (!class_exists('Symfony\Component\Translation\Translator') && $this->isConfigEnabled($container, $config['validation'])) { |
197 | 194 | throw new LogicException('Validation support cannot be enabled as the Translation component is not installed.'); |
198 | 195 | } |
199 | 196 |
|
200 | | - $loader->load('identity_translator.xml'); |
| 197 | + if (class_exists(Translator::class)) { |
| 198 | + $loader->load('identity_translator.xml'); |
| 199 | + } |
201 | 200 | } |
202 | 201 |
|
203 | 202 | if (isset($config['secret'])) { |
@@ -250,7 +249,10 @@ public function load(array $configs, ContainerBuilder $container) |
250 | 249 | $config['validation']['enabled'] = true; |
251 | 250 |
|
252 | 251 | if (!class_exists('Symfony\Component\Validator\Validation')) { |
253 | | - throw new LogicException('The Validator component is required to use the Form component.'); |
| 252 | + $container->setParameter('validator.translation_domain', 'validators'); |
| 253 | + |
| 254 | + $container->removeDefinition('form.type_extension.form.validator'); |
| 255 | + $container->removeDefinition('form.type_guesser.validator'); |
254 | 256 | } |
255 | 257 | } else { |
256 | 258 | $container->removeDefinition('Symfony\Component\Form\Command\DebugCommand'); |
@@ -448,6 +450,10 @@ private function registerFormConfiguration($config, ContainerBuilder $container, |
448 | 450 | } else { |
449 | 451 | $container->setParameter('form.type_extension.csrf.enabled', false); |
450 | 452 | } |
| 453 | + |
| 454 | + if (!class_exists(Translator::class)) { |
| 455 | + $container->removeDefinition('form.type_extension.upload.validator'); |
| 456 | + } |
451 | 457 | } |
452 | 458 |
|
453 | 459 | /** |
|
0 commit comments