bug #25094 [FrameworkBundle][DX] Display a nice error message if an enabled component is missing (derrabus)

This PR was merged into the 3.3 branch.

Discussion
----------

[FrameworkBundle][DX] Display a nice error message if an enabled component is missing

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #25093
| License       | MIT
| Doc PR        | N/A

Commits
-------

2b45805 Display a nice error message if the form/serializer component is missing.
This commit is contained in:
Nicolas Grekas 2017-11-22 12:40:02 +01:00
commit f0270a891e

View File

@ -171,6 +171,10 @@ class FrameworkExtension extends Extension
}
if ($this->isConfigEnabled($container, $config['form'])) {
if (!class_exists('Symfony\Component\Form\Form')) {
throw new LogicException('Form support cannot be enabled as the Form component is not installed.');
}
$this->formConfigEnabled = true;
$this->registerFormConfiguration($config, $container, $loader);
$config['validation']['enabled'] = true;
@ -216,6 +220,10 @@ class FrameworkExtension extends Extension
$this->registerPropertyAccessConfiguration($config['property_access'], $container, $loader);
if ($this->isConfigEnabled($container, $config['serializer'])) {
if (!class_exists('Symfony\Component\Serializer\Serializer')) {
throw new LogicException('Serializer support cannot be enabled as the Serializer component is not installed.');
}
$this->registerSerializerConfiguration($config['serializer'], $container, $loader);
}