From 5bb5e8ce61064df6859779a194fb0e95448c103d Mon Sep 17 00:00:00 2001 From: Dave Mc Nicoll Date: Fri, 12 Sep 2025 19:54:00 +0000 Subject: [PATCH] - Added MethodNotAllowed interface --- meta/definitions/http.php | 16 +++++++--------- src/ApplicationStrategy.php | 5 +++++ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/meta/definitions/http.php b/meta/definitions/http.php index e82c32e..148bfe1 100644 --- a/meta/definitions/http.php +++ b/meta/definitions/http.php @@ -1,15 +1,13 @@ function ($c) { @@ -20,6 +18,10 @@ return [ EmitterInterface::class => create(SapiEmitter::class), + ThrowableHandlerInterface::class => autowire(ThrowableHandler::class), + NotFoundDecoratorInterface::class => autowire(NotFoundDecorator::class), + # MethodNotAllowedInterface::class => autowire(MethodNotAllowedDecorator::class), + HttpFactoryInterface::class => create(HttpFactory::class), 'error.401' => function(ContainerInterface $c, Picea $picea) { @@ -32,9 +34,5 @@ return [ 'error.500' => function(ContainerInterface $c, Picea $picea) { return $c->get(HttpFactoryInterface::class)::createHtmlResponse($picea->renderHtml("lean/error/500", []), 500); - }, - - ThrowableHandlerInterface::class => autowire(ThrowableHandler::class), - NotFoundDecoratorInterface::class => autowire(NotFoundDecorator::class), - # MethodNotAllowedInterface::class => autowire(MethodNotAllowedDecorator::class), + } ]; diff --git a/src/ApplicationStrategy.php b/src/ApplicationStrategy.php index 5ca5196..3e2a255 100644 --- a/src/ApplicationStrategy.php +++ b/src/ApplicationStrategy.php @@ -39,4 +39,9 @@ class ApplicationStrategy extends Strategy\ApplicationStrategy { { return $this->getContainer()->has(MethodNotAllowedInterface::class) ? $this->getContainer()->get(MethodNotAllowedInterface::class) : parent::getMethodNotAllowedDecorator($exception); } + + public function getMethodNotAllowedDecorator(MethodNotAllowedException $exception): MiddlewareInterface + { + return $this->getContainer()->has(MethodNotAllowedInterface::class) ? $this->getContainer()->get(MethodNotAllowedInterface::class) : parent::getMethodNotAllowedDecorator($exception); + } } \ No newline at end of file