You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bug #2178 Throw exception for false combination of twig exception controller and exception_listener configuration (alexander-schranz)
This PR was squashed before being merged into the 2.x branch (closes#2178).
Discussion
----------
Throw exception for false combination of twig exception controller and exception_listener configuration
By default in symfony 4.4 the older exception controller is used so the error handler component is not used. If the exceptionListener is disabled the newer ErrorController need to be used else the mapping configuraiton and listeners don't work.
This would fix#2167 (comment) where on `prefer-lowest` and disabled `exception_listener` the error handler is not called and so the exception not correctly serialized
Commits
-------
e54a336 Throw exception for false combination of twig exception controller and exception_listener configuration
Copy file name to clipboardExpand all lines: DependencyInjection/Compiler/TwigExceptionPass.php
+8Lines changed: 8 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,14 @@ final class TwigExceptionPass implements CompilerPassInterface
24
24
{
25
25
publicfunctionprocess(ContainerBuilder$container)
26
26
{
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
+
thrownew \InvalidArgumentException('You can not disable the "fos_rest.exception.exception_listener" and still have the "twig.exception_controller" enabled.');
33
+
}
34
+
27
35
// when no custom exception controller has been set
28
36
if ($container->hasDefinition('fos_rest.error_listener') &&
0 commit comments