From 06c4f464862cd05d9c4752fc75ed1805c972af24 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 | 2 +- src/ApplicationStrategy.php | 34 ---------------------------------- 2 files changed, 1 insertion(+), 35 deletions(-) diff --git a/meta/definitions/http.php b/meta/definitions/http.php index 148bfe1..07783ea 100644 --- a/meta/definitions/http.php +++ b/meta/definitions/http.php @@ -7,7 +7,7 @@ use Laminas\{ Diactoros\ServerRequestFactory, HttpHandlerRunner\Emitter\EmitterI use Lean\Factory\{ HttpFactory, HttpFactoryInterface }; use Picea\Picea; -use function DI\{ autowire, create, get }; +use function DI\autowire, DI\create, DI\get; return [ ServerRequestInterface::class => function ($c) { diff --git a/src/ApplicationStrategy.php b/src/ApplicationStrategy.php index 265a758..2897e70 100644 --- a/src/ApplicationStrategy.php +++ b/src/ApplicationStrategy.php @@ -32,44 +32,10 @@ class ApplicationStrategy extends Strategy\ApplicationStrategy { public function getThrowableHandler(): MiddlewareInterface { return $this->getContainer()->get(ThrowableHandlerInterface::class); - } public function getMethodNotAllowedDecorator(MethodNotAllowedException $exception): MiddlewareInterface { return $this->getContainer()->has(MethodNotAllowedInterface::class) ? $this->getContainer()->get(MethodNotAllowedInterface::class) : parent::getMethodNotAllowedDecorator($exception); } - /* -<<<<<<< HEAD - public function getMethodNotAllowedDecorator(MethodNotAllowedException $exception): MiddlewareInterface - { - return $this->getContainer()->has(MethodNotAllowedInterface::class) ? $this->getContainer()->get(MethodNotAllowedInterface::class) : parent::getMethodNotAllowedDecorator($exception); -======= - public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface - { - if (php_sapi_name() !== 'cli' and ! defined('STDIN')) { - return $this->throw404($request); - } - - return $handler->handle($request);; - } - - public function throw404(ServerRequestInterface $request) : ResponseInterface - { - if ( getenv('DEBUG') && $this->di->has(\Picea\Asset\Asset::class) ) { - $params = $request->getServerParams(); - - $scpName = basename(explode('?', $params['REQUEST_URI'] ?? "", 2)[0]); - list(, $ext) = array_pad(explode('.', $scpName), 2, null); - - if ($ext && in_array($ext, ApplicationStrategy::ASSET_TRIGGER_UPDATE)) { - $this->di->get(\Picea\Asset\Asset::class)->launchInstall(); - } - } - - return $this->di->get('error.404'); - } - }; ->>>>>>> af8b686 (- WIP on ulmus-user mechanics updates) - }*/ } \ No newline at end of file