Navigation Menu

Skip to content

Commit

Permalink
bug #34062 [TwigBundle] allow option "twig.exception_controller" to b…
Browse files Browse the repository at this point in the history
…e null on Symfony 5 (nicolas-grekas)

This PR was merged into the 5.0-dev branch.

Discussion
----------

[TwigBundle] allow option "twig.exception_controller" to be null on Symfony 5

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Otherwise, it's really hard for bundles to allow v5 while still supporting v4/v3.

Commits
-------

816996e [TwigBundle] allow option "twig.exception_controller" to be null on Symfony 5
  • Loading branch information
nicolas-grekas committed Oct 22, 2019
2 parents ff6078e + 816996e commit ae65c4d
Showing 1 changed file with 14 additions and 0 deletions.
Expand Up @@ -14,6 +14,7 @@
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;

/**
* TwigExtension configuration structure.
Expand All @@ -32,6 +33,19 @@ public function getConfigTreeBuilder()
$treeBuilder = new TreeBuilder('twig');
$rootNode = $treeBuilder->getRootNode();

$rootNode->beforeNormalization()
->ifTrue(function ($v) { return \is_array($v) && \array_key_exists('exception_controller', $v); })
->then(function ($v) {
if (isset($v['exception_controller'])) {
throw new InvalidConfigurationException('Option "exception_controller" under "twig" must be null or unset, use "error_controller" under "framework" instead.');
}

unset($v['exception_controller']);

return $v;
})
->end();

$this->addFormThemesSection($rootNode);
$this->addGlobalsSection($rootNode);
$this->addTwigOptions($rootNode);
Expand Down

0 comments on commit ae65c4d

Please sign in to comment.