1
0
mirror of https://github.com/flarum/core.git synced 2025-08-07 17:07:19 +02:00

Provide frontend string as param to ExecuteErrorToFrontend handler

This commit is contained in:
Alexander Skvortsov
2021-04-13 01:47:20 -04:00
parent 7cf0df88f3
commit 2c8cc0c92b
2 changed files with 9 additions and 3 deletions

View File

@@ -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;
});

View File

@@ -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());
}