From fdca37a79d2648cddbdcd51bb8e63c3d2a452447 Mon Sep 17 00:00:00 2001 From: Dave Mc Nicoll Date: Sat, 20 Dec 2025 12:44:13 -0500 Subject: [PATCH] - Added createStream methods and fixed multiple errors views --- src/ApplicationStrategy/NotFoundDecorator.php | 2 +- src/Factory/HttpFactory.php | 7 +++++++ src/Factory/HttpFactoryInterface.php | 3 +++ view/lean/error/401.phtml | 2 +- view/lean/error/404.phtml | 6 ------ view/lean/error/500.phtml | 8 +------- view/lean/layout/error.phtml | 4 ++-- view/lean/picto/undraw_error.phtml | 2 +- view/lean/picto/undraw_forbidden.phtml | 2 +- 9 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/ApplicationStrategy/NotFoundDecorator.php b/src/ApplicationStrategy/NotFoundDecorator.php index 706dd70..8ce628f 100644 --- a/src/ApplicationStrategy/NotFoundDecorator.php +++ b/src/ApplicationStrategy/NotFoundDecorator.php @@ -34,7 +34,7 @@ class NotFoundDecorator implements NotFoundDecoratorInterface return $this->throw404($request); } - return $handler->handle($request);; + return $handler->handle($request); } public function throw404(ServerRequestInterface $request) : ResponseInterface diff --git a/src/Factory/HttpFactory.php b/src/Factory/HttpFactory.php index 1ab5214..390bf4f 100644 --- a/src/Factory/HttpFactory.php +++ b/src/Factory/HttpFactory.php @@ -5,7 +5,9 @@ namespace Lean\Factory; use Laminas\Diactoros\Response\{EmptyResponse, HtmlResponse, JsonResponse, RedirectResponse, TextResponse}; use Lean\Response\{ DownloadResponse, ImageResponse, FileDownloadResponse, PdfResponse }; use Laminas\Diactoros\Response; +use Laminas\Diactoros\StreamFactory; use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\StreamInterface; class HttpFactory implements HttpFactoryInterface { @@ -58,4 +60,9 @@ class HttpFactory implements HttpFactoryInterface { return new FileDownloadResponse($path, $code, $headers); } + + public static function createStream(string $content): StreamInterface + { + return new StreamFactory()->createStream($content); + } } diff --git a/src/Factory/HttpFactoryInterface.php b/src/Factory/HttpFactoryInterface.php index 4ef594b..81a6173 100644 --- a/src/Factory/HttpFactoryInterface.php +++ b/src/Factory/HttpFactoryInterface.php @@ -6,6 +6,7 @@ use Laminas\Diactoros\Response\{EmptyResponse, HtmlResponse, JsonResponse, Redir use Lean\Response\{ DownloadResponse, ImageResponse, FileDownloadResponse, PdfResponse }; use Laminas\Diactoros\Response; use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\StreamInterface; interface HttpFactoryInterface { @@ -19,4 +20,6 @@ interface HttpFactoryInterface public static function createDownloadableResponse(string $data, string $filename, int $code = 200, array $headers = []) : ResponseInterface; public static function createImageResponse(string $data, int $code = 200, array $headers = []) : ResponseInterface; public static function createFileDownloadResponse(string $path, int $code = 200, array $headers = []) : ResponseInterface; + + public static function createStream(string $content) : StreamInterface; } diff --git a/view/lean/error/401.phtml b/view/lean/error/401.phtml index f421d07..a022eab 100644 --- a/view/lean/error/401.phtml +++ b/view/lean/error/401.phtml @@ -22,5 +22,5 @@ {% section "head.css" %} .title {font-size:2rem} .subtitle {font-size:1.25rem; padding-top: 1rem;} - .content {padding-top:1rem} + .content {background: #f7f7f7;padding: 7px;color: #8c3c3c;max-height:300px;overflow-y:auto} {% endsection %} diff --git a/view/lean/error/404.phtml b/view/lean/error/404.phtml index fdcc1f4..c2021c9 100644 --- a/view/lean/error/404.phtml +++ b/view/lean/error/404.phtml @@ -18,9 +18,3 @@ {% view "lean/picto/undraw_lost" %} {% endsection %} - -{% section "head.css" %} - .title {font-size:2rem} - .subtitle {font-size:1.25rem; padding-top: 1rem;} - .content {padding-top:1rem} -{% endsection %} diff --git a/view/lean/error/500.phtml b/view/lean/error/500.phtml index 0bad0a1..dba3c27 100644 --- a/view/lean/error/500.phtml +++ b/view/lean/error/500.phtml @@ -17,10 +17,4 @@
{% view "lean/picto/undraw_error" %}
-{% endsection %} - -{% section "head.css" %} - .title {font-size:2rem} - .subtitle {font-size:1.25rem; padding-top: 1rem;} - .content {background: #f7f7f7;padding: 7px;color: #8c3c3c;max-height:300px;overflow-y:auto} -{% endsection %} +{% endsection %} \ No newline at end of file diff --git a/view/lean/layout/error.phtml b/view/lean/layout/error.phtml index f73f918..343165e 100644 --- a/view/lean/layout/error.phtml +++ b/view/lean/layout/error.phtml @@ -10,14 +10,14 @@ diff --git a/view/lean/picto/undraw_error.phtml b/view/lean/picto/undraw_error.phtml index a95cd1f..0daa182 100644 --- a/view/lean/picto/undraw_error.phtml +++ b/view/lean/picto/undraw_error.phtml @@ -1 +1 @@ -bug fixing \ No newline at end of file diff --git a/view/lean/picto/undraw_forbidden.phtml b/view/lean/picto/undraw_forbidden.phtml index c8a514c..23fcecb 100644 --- a/view/lean/picto/undraw_forbidden.phtml +++ b/view/lean/picto/undraw_forbidden.phtml @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file