bug #11839 [FrameworkBundle] check if the Validator component is present when forms are enabled (xabbuh)

This PR was merged into the 2.5 branch.

Discussion
----------

[FrameworkBundle] check if the Validator component is present when forms are enabled

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

The `Symfony\Component\Validator\Validation` class is used in the
`FrameworkExtension` class. Therefore, it is required to have the
Validator component installed in production as well but not only when
being in a development environment.

Commits
-------

ed41da1 check for the Validator if forms are enabled
This commit is contained in:
Fabien Potencier 2014-09-22 18:56:03 +02:00
commit 33b30a839f

View File

@ -14,6 +14,7 @@ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\DefinitionDecorator;
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\Config\Resource\FileResource;
@ -103,6 +104,10 @@ class FrameworkExtension extends Extension
$this->registerFormConfiguration($config, $container, $loader);
$config['validation']['enabled'] = true;
if (!class_exists('Symfony\Component\Validator\Validator')) {
throw new LogicException('The Validator component is required to use the Form component.');
}
if ($this->isConfigEnabled($container, $config['form']['csrf_protection'])) {
$config['csrf_protection']['enabled'] = true;
}