From 6935b2ebe2c20e5cafa3fdbd999bc78d84e640d4 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Mon, 26 Mar 2018 20:37:04 +0200 Subject: [PATCH] Updated system so that NotFoundDelegate is used --- config/autoload/middleware-pipeline.global.php | 3 ++- module/Core/src/Response/NotFoundDelegate.php | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/config/autoload/middleware-pipeline.global.php b/config/autoload/middleware-pipeline.global.php index 5249b0de..dad75c13 100644 --- a/config/autoload/middleware-pipeline.global.php +++ b/config/autoload/middleware-pipeline.global.php @@ -2,6 +2,7 @@ declare(strict_types=1); use Shlinkio\Shlink\Common\Middleware\LocaleMiddleware; +use Shlinkio\Shlink\Core\Response\NotFoundDelegate; use Shlinkio\Shlink\Rest\Middleware\BodyParserMiddleware; use Shlinkio\Shlink\Rest\Middleware\CheckAuthenticationMiddleware; use Shlinkio\Shlink\Rest\Middleware\CrossDomainMiddleware; @@ -48,7 +49,7 @@ return [ 'post-routing' => [ 'middleware' => [ Expressive\Router\Middleware\DispatchMiddleware::class, - Expressive\Handler\NotFoundHandler::class, + NotFoundDelegate::class, ], 'priority' => 1, ], diff --git a/module/Core/src/Response/NotFoundDelegate.php b/module/Core/src/Response/NotFoundDelegate.php index 2698625a..db5ab040 100644 --- a/module/Core/src/Response/NotFoundDelegate.php +++ b/module/Core/src/Response/NotFoundDelegate.php @@ -39,12 +39,12 @@ class NotFoundDelegate implements DelegateInterface */ public function handle(ServerRequestInterface $request): ResponseInterface { - $accepts = explode(',', $request->getHeaderLine('Accept')); - $accept = array_shift($accepts); + $accepts = \explode(',', $request->getHeaderLine('Accept')); + $accept = \array_shift($accepts); $status = StatusCodeInterface::STATUS_NOT_FOUND; // If the first accepted type is json, return a json response - if (in_array($accept, ['application/json', 'text/json', 'application/x-json'], true)) { + if (\in_array($accept, ['application/json', 'text/json', 'application/x-json'], true)) { return new Response\JsonResponse([ 'error' => 'NOT_FOUND', 'message' => 'Not found',