Skip to content

Commit e54a336

Browse files
alexander-schranzxabbuh
authored andcommitted
Throw exception for false combination of twig exception controller and exception_listener configuration
1 parent 4535d1a commit e54a336

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

DependencyInjection/Compiler/TwigExceptionPass.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ final class TwigExceptionPass implements CompilerPassInterface
2424
{
2525
public function process(ContainerBuilder $container)
2626
{
27+
if ($container->hasDefinition('fos_rest.exception.codes_map') // is config exception.enabled true
28+
&& $container->hasParameter('twig.exception_listener.controller') // is twig-bundle 4.4 installed
29+
&& $container->getParameter('twig.exception_listener.controller') // is twig-bundle deprecated controller set
30+
&& !$container->hasDefinition('fos_rest.exception_listener') // is deprecated exception_listener disabled
31+
) {
32+
throw new \InvalidArgumentException('You can not disable the "fos_rest.exception.exception_listener" and still have the "twig.exception_controller" enabled.');
33+
}
34+
2735
// when no custom exception controller has been set
2836
if ($container->hasDefinition('fos_rest.error_listener') &&
2937
null === $container->getDefinition('fos_rest.error_listener')->getArgument(0)

Tests/Functional/app/RequestBodyParamConverterTwigBundle/config.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ framework:
1111
fos_rest:
1212
body_converter:
1313
enabled: true
14-
exception:
15-
exception_listener: false
1614
routing_loader: false
1715

1816
sensio_framework_extra:

0 commit comments

Comments
 (0)