From 5c06419f15a408ed50a732c6ac44d69148cf597d Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 11 May 2022 12:32:05 +0000 Subject: [PATCH 1/2] - Quick method to render an error view --- src/ControllerTrait.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ControllerTrait.php b/src/ControllerTrait.php index d47f216..9bb5e59 100644 --- a/src/ControllerTrait.php +++ b/src/ControllerTrait.php @@ -61,6 +61,13 @@ trait ControllerTrait { ); } + public function renderError(string $errorCode, ?array $variables = null) : ResponseInterface + { + return static::renderHtml( + $this->renderRawView("$lean/error/{$code}", $variables ?? []) + ); + } + public function renderDocumentation(string $filename) : ResponseInterface { return $this->renderMarkdown( file_get_contents(getenv("PROJECT_PATH") . "/meta/doc/$filename.md") ); From a78d20bc3267ca7497274d5579774a69ce842722 Mon Sep 17 00:00:00 2001 From: Dave Mc Nicoll Date: Wed, 11 May 2022 12:34:38 +0000 Subject: [PATCH 2/2] - Previous commit wasn't a completed feature ; now it is --- src/ControllerTrait.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/ControllerTrait.php b/src/ControllerTrait.php index 9bb5e59..8a80e1a 100644 --- a/src/ControllerTrait.php +++ b/src/ControllerTrait.php @@ -64,7 +64,7 @@ trait ControllerTrait { public function renderError(string $errorCode, ?array $variables = null) : ResponseInterface { return static::renderHtml( - $this->renderRawView("$lean/error/{$code}", $variables ?? []) + $this->renderRawView("lean/error/{$errorCode}", $variables ?? []) ); } @@ -74,10 +74,6 @@ trait ControllerTrait { } protected function redirect(string $url, int $code = 302, array $headers = []) { - if ($code === 302 && empty(array_change_key_case($headers, CASE_LOWER)['cache-control'])) { - $headers['cache-control'] = 'no-store'; - } - return new RedirectResponse($url, $code, $headers); }