Restructure Flarum\Forum namespace

This commit is contained in:
Franz Liedke 2017-06-24 12:08:04 +02:00
parent 0be13d50bd
commit 927e4ca3ed
No known key found for this signature in database
GPG Key ID: 9A0231A879B055F4
3 changed files with 88 additions and 67 deletions

View File

@ -56,82 +56,21 @@ class ForumServiceProvider extends AbstractServiceProvider
*/
protected function populateRoutes(RouteCollection $routes)
{
$route = $this->app->make(RouteHandlerFactory::class);
$factory = $this->app->make(RouteHandlerFactory::class);
$routes->get(
'/all',
'index',
$toDefaultController = $route->toController(Controller\IndexController::class)
);
$routes->get(
'/d/{id:\d+(?:-[^/]*)?}[/{near:[^/]*}]',
'discussion',
$route->toController(Controller\DiscussionController::class)
);
$routes->get(
'/u/{username}[/{filter:[^/]*}]',
'user',
$route->toController(Controller\FrontendController::class)
);
$routes->get(
'/settings',
'settings',
$route->toController(Controller\AuthorizedWebAppController::class)
);
$routes->get(
'/notifications',
'notifications',
$route->toController(Controller\AuthorizedWebAppController::class)
);
$routes->get(
'/logout',
'logout',
$route->toController(Controller\LogOutController::class)
);
$routes->post(
'/login',
'login',
$route->toController(Controller\LogInController::class)
);
$routes->post(
'/register',
'register',
$route->toController(Controller\RegisterController::class)
);
$routes->get(
'/confirm/{token}',
'confirmEmail',
$route->toController(Controller\ConfirmEmailController::class)
);
$routes->get(
'/reset/{token}',
'resetPassword',
$route->toController(Controller\ResetPasswordController::class)
);
$routes->post(
'/reset',
'savePassword',
$route->toController(Controller\SavePasswordController::class)
);
$callback = include __DIR__.'/routes.php';
$callback($routes, $factory);
$this->app->make('events')->fire(
new ConfigureForumRoutes($routes, $route)
new ConfigureForumRoutes($routes, $factory)
);
$defaultRoute = $this->app->make('flarum.settings')->get('default_route');
if (isset($routes->getRouteData()[0]['GET'][$defaultRoute])) {
$toDefaultController = $routes->getRouteData()[0]['GET'][$defaultRoute];
} else {
$toDefaultController = $factory->toController(Controller\IndexController::class);
}
$routes->get(

82
src/Forum/routes.php Normal file
View File

@ -0,0 +1,82 @@
<?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Flarum\Forum\Controller;
use Flarum\Http\Handler\RouteHandlerFactory;
use Flarum\Http\RouteCollection;
return function (RouteCollection $map, RouteHandlerFactory $route) {
$map->get(
'/all',
'index',
$route->toController(Controller\IndexController::class)
);
$map->get(
'/d/{id:\d+(?:-[^/]*)?}[/{near:[^/]*}]',
'discussion',
$route->toController(Controller\DiscussionController::class)
);
$map->get(
'/u/{username}[/{filter:[^/]*}]',
'user',
$route->toController(Controller\FrontendController::class)
);
$map->get(
'/settings',
'settings',
$route->toController(Controller\AuthorizedWebAppController::class)
);
$map->get(
'/notifications',
'notifications',
$route->toController(Controller\AuthorizedWebAppController::class)
);
$map->get(
'/logout',
'logout',
$route->toController(Controller\LogOutController::class)
);
$map->post(
'/login',
'login',
$route->toController(Controller\LogInController::class)
);
$map->post(
'/register',
'register',
$route->toController(Controller\RegisterController::class)
);
$map->get(
'/confirm/{token}',
'confirmEmail',
$route->toController(Controller\ConfirmEmailController::class)
);
$map->get(
'/reset/{token}',
'resetPassword',
$route->toController(Controller\ResetPasswordController::class)
);
$map->post(
'/reset',
'savePassword',
$route->toController(Controller\SavePasswordController::class)
);
};