diff --git a/src/Forum/ForumServiceProvider.php b/src/Forum/ForumServiceProvider.php index bddc2d626..877b35cb5 100644 --- a/src/Forum/ForumServiceProvider.php +++ b/src/Forum/ForumServiceProvider.php @@ -149,7 +149,7 @@ class ForumServiceProvider extends AbstractServiceProvider } } - $pipe->pipe(new ExecuteErrorToFrontend($this->container->make(RouteHandlerFactory::class))); + $pipe->pipe(new ExecuteErrorToFrontend('forum', $this->container->make(RouteHandlerFactory::class))); return $pipe; }); diff --git a/src/Foundation/ErrorHandling/Middleware/ExecuteErrorToFrontend.php b/src/Foundation/ErrorHandling/Middleware/ExecuteErrorToFrontend.php index 3cd7d3df8..d6c3e76bd 100644 --- a/src/Foundation/ErrorHandling/Middleware/ExecuteErrorToFrontend.php +++ b/src/Foundation/ErrorHandling/Middleware/ExecuteErrorToFrontend.php @@ -10,12 +10,18 @@ use Psr\Http\Server\RequestHandlerInterface; class ExecuteErrorToFrontend implements MiddlewareInterface { + /** + * @var string + */ + protected $frontend; + /** * @var RouteHandlerFactory */ protected $handlerFactory; - public function __construct(RouteHandlerFactory $handlerFactory) { + public function __construct(string $frontend, RouteHandlerFactory $handlerFactory) { + $this->frontend = $frontend; $this->handlerFactory = $handlerFactory; } @@ -24,7 +30,7 @@ class ExecuteErrorToFrontend implements MiddlewareInterface $error = $request->getAttribute('error'); $contentClass = $error->contentClass(); - $controller = $this->handlerFactory->toFrontend('forum', new $contentClass); + $controller = $this->handlerFactory->toFrontend($this->frontend, new $contentClass); return $controller($request, [])->withStatus($error->getStatusCode()); }