mirror of
https://github.com/flarum/framework.git
synced 2024-12-02 15:03:44 +08:00
Restructure Flarum\Forum namespace
This commit is contained in:
parent
5e9308fb4c
commit
0324045f6c
|
@ -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
framework/core/src/Forum/routes.php
Normal file
82
framework/core/src/Forum/routes.php
Normal 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)
|
||||
);
|
||||
};
|
Loading…
Reference in New Issue
Block a user