catchAdmin/extend/catcher/event/LoadModuleRoutes.php

49 lines
1.0 KiB
PHP
Raw Normal View History

2019-12-06 09:17:40 +08:00
<?php
declare (strict_types = 1);
namespace catcher\event;
use catcher\CatchAdmin;
use think\Route;
class LoadModuleRoutes
{
/**
* 处理
*
* @time 2019年11月29日
* @return void
*/
public function handle(): void
{
$router = app(Route::class);
2019-12-15 17:26:40 +08:00
$domain = config('catch.domain');
if ($domain) {
$router->domain($domain, function () use ($router) {
foreach ($this->getRoutes() as $route) {
include $route;
}
});
} else {
$router->group(function () use ($router) {
foreach ($this->getRoutes() as $route) {
include $route;
}
});
}
2019-12-06 09:17:40 +08:00
}
2019-12-14 18:21:29 +08:00
2019-12-15 15:51:00 +08:00
/**
*
* @time 2019年12月15日
* @return array
*/
protected function getRoutes(): array
2019-12-14 18:21:29 +08:00
{
2019-12-15 15:51:00 +08:00
$routes = CatchAdmin::getRoutes();
$routes[] = CatchAdmin::directory() . 'login' . DIRECTORY_SEPARATOR . 'route.php';
return $routes;
2019-12-14 18:21:29 +08:00
}
2019-12-06 09:17:40 +08:00
}