mirror of
https://github.com/getgrav/grav.git
synced 2026-02-09 08:07:49 +01:00
Fixed RequestHandlers NotFoundException having empty request
This commit is contained in:
@@ -21,9 +21,6 @@ use function in_array;
|
||||
*/
|
||||
class NotFoundException extends RequestException
|
||||
{
|
||||
/** @var ServerRequestInterface */
|
||||
private $request;
|
||||
|
||||
/**
|
||||
* NotFoundException constructor.
|
||||
* @param ServerRequestInterface $request
|
||||
@@ -37,9 +34,4 @@ class NotFoundException extends RequestException
|
||||
parent::__construct($request, 'Not Found', 404, $previous);
|
||||
}
|
||||
}
|
||||
|
||||
public function getRequest(): ServerRequestInterface
|
||||
{
|
||||
return $this->request;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,9 +12,11 @@ declare(strict_types=1);
|
||||
namespace Grav\Framework\RequestHandler;
|
||||
|
||||
use Grav\Framework\RequestHandler\Traits\RequestHandlerTrait;
|
||||
use Pimple\Container;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\Http\Server\MiddlewareInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
use function assert;
|
||||
|
||||
/**
|
||||
* Class RequestHandler
|
||||
@@ -47,7 +49,11 @@ class RequestHandler implements RequestHandlerInterface
|
||||
*/
|
||||
public function addCallable(string $name, callable $callable): self
|
||||
{
|
||||
$this->container[$name] = $callable;
|
||||
if (null !== $this->container) {
|
||||
assert($this->container instanceof Container);
|
||||
$this->container[$name] = $callable;
|
||||
}
|
||||
|
||||
array_unshift($this->middleware, $name);
|
||||
|
||||
return $this;
|
||||
@@ -62,7 +68,11 @@ class RequestHandler implements RequestHandlerInterface
|
||||
*/
|
||||
public function addMiddleware(string $name, MiddlewareInterface $middleware): self
|
||||
{
|
||||
$this->container[$name] = $middleware;
|
||||
if (null !== $this->container) {
|
||||
assert($this->container instanceof Container);
|
||||
$this->container[$name] = $middleware;
|
||||
}
|
||||
|
||||
array_unshift($this->middleware, $name);
|
||||
|
||||
return $this;
|
||||
|
||||
Reference in New Issue
Block a user