diff --git a/src/Events/RegisterForumRoutes.php b/src/Events/RegisterForumRoutes.php index d859930b5..0e7598644 100644 --- a/src/Events/RegisterForumRoutes.php +++ b/src/Events/RegisterForumRoutes.php @@ -1,6 +1,7 @@ routes = $routes; } + + public function get($url, $name, $action = 'Flarum\Forum\Actions\IndexAction') + { + $this->route('get', $url, $name, $action); + } + + protected function route($method, $url, $name, $action) + { + $this->routes->$method($url, $name, $this->action($action)); + } + + protected function action($class) + { + return function (ServerRequestInterface $httpRequest, $routeParams) use ($class) { + /** @var \Flarum\Support\Action $action */ + $action = app($class); + + return $action->handle($httpRequest, $routeParams); + }; + } }