Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Stopwatch\Stopwatch;
use Symfony\Component\Translation\Command\XliffLintCommand as BaseXliffLintCommand;
use Symfony\Component\Translation\Translator;
use Symfony\Component\Validator\ConstraintValidatorInterface;
use Symfony\Component\Validator\ObjectInitializerInterface;
use Symfony\Component\WebLink\HttpHeaderSerializer;
Expand Down Expand Up @@ -189,15 +190,13 @@ public function load(array $configs, ContainerBuilder $container)
throw new LogicException('Translation support cannot be enabled as the Translation component is not installed.');
}

if (!class_exists('Symfony\Component\Translation\Translator') && $this->isConfigEnabled($container, $config['form'])) {
throw new LogicException('Form support cannot be enabled as the Translation component is not installed.');
}

if (!class_exists('Symfony\Component\Translation\Translator') && $this->isConfigEnabled($container, $config['validation'])) {
throw new LogicException('Validation support cannot be enabled as the Translation component is not installed.');
}

$loader->load('identity_translator.xml');
if (class_exists(Translator::class)) {
$loader->load('identity_translator.xml');
}
}

if (isset($config['secret'])) {
Expand Down Expand Up @@ -250,7 +249,10 @@ public function load(array $configs, ContainerBuilder $container)
$config['validation']['enabled'] = true;

if (!class_exists('Symfony\Component\Validator\Validation')) {
throw new LogicException('The Validator component is required to use the Form component.');
$container->setParameter('validator.translation_domain', 'validators');

$container->removeDefinition('form.type_extension.form.validator');
$container->removeDefinition('form.type_guesser.validator');
}
} else {
$container->removeDefinition('Symfony\Component\Form\Command\DebugCommand');
Expand Down Expand Up @@ -448,6 +450,10 @@ private function registerFormConfiguration($config, ContainerBuilder $container,
} else {
$container->setParameter('form.type_extension.csrf.enabled', false);
}

if (!class_exists(Translator::class)) {
$container->removeDefinition('form.type_extension.upload.validator');
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<argument type="service" id="security.csrf.token_manager" />
<argument>%form.type_extension.csrf.enabled%</argument>
<argument>%form.type_extension.csrf.field_name%</argument>
<argument type="service" id="translator" />
<argument type="service" id="translator" on-invalid="null" />
<argument>%validator.translation_domain%</argument>
<argument type="service" id="form.server_params" />
</service>
Expand Down