Skip to content

Commit

Permalink
[TwigBundle] allow option "twig.exception_controller" to be null on S…
Browse files Browse the repository at this point in the history
…ymfony 5
  • Loading branch information
nicolas-grekas committed Oct 22, 2019
1 parent ff6078e commit 816996e
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 816996e

Please sign in to comment.