From 3457f93ed0365736a4fbc121cdcabf7d03b458b6 Mon Sep 17 00:00:00 2001 From: Kevin Papst Date: Thu, 4 Jul 2019 17:00:55 +0200 Subject: [PATCH] fix 500 happening in error pages (#914) --- src/Event/ThemeEvent.php | 19 +++++++------------ .../TwigBundle/Exception/error500.html.twig | 15 ++++++--------- templates/error.html.twig | 2 +- 3 files changed, 14 insertions(+), 22 deletions(-) diff --git a/src/Event/ThemeEvent.php b/src/Event/ThemeEvent.php index 3be8e41e..1089f1e6 100644 --- a/src/Event/ThemeEvent.php +++ b/src/Event/ThemeEvent.php @@ -23,7 +23,7 @@ final class ThemeEvent extends Event public const CONTENT_AFTER = 'app.theme.content_after'; /** - * @var User + * @var User|null */ protected $user; /** @@ -35,33 +35,28 @@ final class ThemeEvent extends Event */ protected $payload = null; - public function __construct(User $user, $payload = null) + public function __construct(?User $user = null, $payload = null) { $this->user = $user; $this->payload = $payload; } /** - * @return User + * @deprecated since 1.0 */ - public function getUser() + public function getUser(): ?User { + @trigger_error('Using ThemeEvent::getUser() is deprecated and will be removed with 2.0', E_USER_DEPRECATED); + return $this->user; } - /** - * @return string - */ public function getContent(): string { return $this->content; } - /** - * @param string $content - * @return ThemeEvent - */ - public function addContent(string $content) + public function addContent(string $content): ThemeEvent { $this->content .= $content; diff --git a/templates/bundles/TwigBundle/Exception/error500.html.twig b/templates/bundles/TwigBundle/Exception/error500.html.twig index 01ed8b4b..f2ad5372 100644 --- a/templates/bundles/TwigBundle/Exception/error500.html.twig +++ b/templates/bundles/TwigBundle/Exception/error500.html.twig @@ -1,10 +1,7 @@ -{# - This template is used to render errors of type HTTP 500 (Internal Server Error) +{% extends 'error.html.twig' %} - This is the simplest way to customize error pages in Symfony applications. - In case you need it, you can also hook into the internal exception handling - made by Symfony. This allows you to perform advanced tasks and even recover - your application from some errors. - See http://symfony.com/doc/current/cookbook/controller/error_pages.html -#} -{% extends '@Twig/Exception/error.html.twig' %} +{% block error_icon %} + +{% endblock %} + +{% block error_class %}text-red{% endblock %} \ No newline at end of file diff --git a/templates/error.html.twig b/templates/error.html.twig index 64efb577..e99a9377 100644 --- a/templates/error.html.twig +++ b/templates/error.html.twig @@ -19,7 +19,7 @@ {% endif %}
-

{{ status_code }}

+

{{ status_code }}

{% block error_content %}