8000 [TwigBundle] remove deprecations and fix tests by Tobion · Pull Request #32696 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[TwigBundle] remove deprecations and fix tests #32696

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 0 additions & 148 deletions src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ public function getConfigTreeBuilder()
$rootNode
->children()
->scalarNode('exception_controller')
->defaultValue(static function () {
@trigger_error('Relying on the default value ("twig.controller.exception::showAction") of the "twig.exception_controller" configuration option is deprecated since Symfony 4.4, set it to "null" explicitly instead, which will be the new default in 5.0.', E_USER_DEPRECATED);

return 'twig.controller.exception::showAction';
})
->defaultNull()
->end()
->end()
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
use Symfony\Component\ErrorRenderer\ErrorRenderer\HtmlErrorRenderer;
use Symfony\Component\ErrorRenderer\Exception\FlattenException;
use Twig\Environment;
use Twig\Error\LoaderError;
use Twig\Loader\ExistsLoaderInterface;

/**
* Provides the ability to render custom Twig-based HTML error pages
Expand Down Expand Up @@ -63,7 +61,6 @@ public function render(FlattenException $exception): string
}

return $this->twig->render($template, [
'legacy' => false, // to be removed in 5.0
'exception' => $exception,
'status_code' => $exception->getStatusCode(),
'status_text' => $exception->getTitle(),
Expand All @@ -73,39 +70,15 @@ public function render(FlattenException $exception): string
private function findTemplate(int $statusCode): ?string
{
$template = sprintf('@Twig/Exception/error%s.html.twig', $statusCode);
if ($this->templateExists($template)) {
if ($this->twig->getLoader()->exists($template)) {
return $template;
}

$template = '@Twig/Exception/error.html.twig';
if ($this->templateExists($template)) {
if ($this->twig->getLoader()->exists($template)) {
return $template;
}

return null;
}

/**
* To be removed in 5.0.
*
* Use instead:
*
* $this->twig->getLoader()->exists($template)
*/
private function templateExists(string $template): bool
{
$loader = $this->twig->getLoader();
if ($loader instanceof ExistsLoaderInterface || method_exists($loader, 'exists')) {
return $loader->exists($template);
}

try {
$loader->getSourceContext($template);

return true;
} catch (LoaderError $e) {
}

return false;
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
0