winter/modules/backend/routes.php
Marc Jauvin 9a6f71e0d4
Fix route order with new system.beforeRoute and system.route events (#465)
With the recent change to module routes being registered in their boot methods the Backend & CMS modules were registering their routes before the System module could. 

Due to the greedy nature of the CMS module's route it must always be registered last.
2022-02-21 12:28:09 -06:00

50 lines
1.1 KiB
PHP

<?php
Event::listen('system.route', function () {
/**
* Register Backend routes before all user routes.
*/
/**
* @event backend.beforeRoute
* Fires before backend routes get added
*
* Example usage:
*
* Event::listen('backend.beforeRoute', function () {
* // your code here
* });
*
*/
Event::fire('backend.beforeRoute');
/*
* Other pages
*/
Route::group([
'middleware' => ['web'],
'prefix' => Config::get('cms.backendUri', 'backend')
], function () {
Route::any('{slug?}', 'Backend\Classes\BackendController@run')->where('slug', '(.*)?');
});
/*
* Entry point
*/
Route::any(Config::get('cms.backendUri', 'backend'), 'Backend\Classes\BackendController@run')->middleware('web');
/**
* @event backend.route
* Fires after backend routes have been added
*
* Example usage:
*
* Event::listen('backend.route', function () {
* // your code here
* });
*
*/
Event::fire('backend.route');
});