Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix removal of fos_rest.exception.twig_controller when templating/twig is not enabled #2012

Closed
wants to merge 2 commits into from

Conversation

Tobion
Copy link
Member

@Tobion Tobion commented Jul 30, 2019

Fixes #1772, #1887, #1945, #2002

With that you can remove

framework:
    templating:
        engines: twig

which fixes the deprecations and it will use \FOS\RestBundle\Controller\ExceptionController instead of \FOS\RestBundle\Controller\TwigExceptionController correctly. This in turn means it does not use the TwigBundle error rendering but the implementation using the Serializer (Symfony or JMS). But the error response stays the same because of \FOS\RestBundle\Serializer\Normalizer\ExceptionHandler::convertToArray (or the equivalent for Symfony serializer).
So people can disable templating and twig and error rendering should still be BC.

The following part is not needed anymore with #2015
If people use TwigBundle but want to disable SF templating part to get rid of deprecations, they need to set

fos_rest:
    exception:
        exception_controller: 'fos_rest.exception.controller::showAction'

because otherwise the unwanted twig controller get's used again:

if ($config['exception']['exception_controller']) {
$controller = $config['exception']['exception_controller'];
} elseif (isset($container->getParameter('kernel.bundles')['TwigBundle'])) {
if (Kernel::VERSION_ID >= 40100) {
$controller = 'fos_rest.exception.twig_controller::showAction';
} else {
$controller = 'fos_rest.exception.twig_controller:showAction';
}

@Tobion
Copy link
Member Author

Tobion commented Jul 30, 2019

Test failures unrelated and already failed before...

@Tobion
Copy link
Member Author

Tobion commented Jul 30, 2019

For Symfony 4.4 compatibility we likely can remove/deprecate parts of the exception controllers and listeners etc as it will be obsolete with the new ErrorRenderer component. But that is a future topic to handle.

Copy link
Member

@GuilhemN GuilhemN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me as well 👍

@xabbuh
Copy link
Member

xabbuh commented Jul 31, 2019

Thank you @Tobion.

@xabbuh xabbuh closed this in 46df4f3 Jul 31, 2019
@xabbuh xabbuh deleted the fix-templating-dependency branch July 31, 2019 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Symfony Flex (3.3) - Dependency with Twig
3 participants