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:
@@ -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;
|
||||
});
|
||||
|
@@ -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());
|
||||
}
|
||||
|
Reference in New Issue
Block a user