架构调整,服务调整
This commit is contained in:
parent
9125292aa8
commit
ee04005d69
@ -18,6 +18,7 @@ use catcher\command\Tools\ExportDataCommand;
|
|||||||
use catcher\command\Tools\MakeMenuCommand;
|
use catcher\command\Tools\MakeMenuCommand;
|
||||||
use catcher\command\worker\ExcelTaskCommand;
|
use catcher\command\worker\ExcelTaskCommand;
|
||||||
use catcher\command\worker\WsWorkerCommand;
|
use catcher\command\worker\WsWorkerCommand;
|
||||||
|
use catcher\event\LoadModuleRoutes;
|
||||||
use think\exception\Handle;
|
use think\exception\Handle;
|
||||||
use think\facade\Validate;
|
use think\facade\Validate;
|
||||||
use think\Service;
|
use think\Service;
|
||||||
@ -30,8 +31,7 @@ class CatchAdminService extends Service
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function boot()
|
public function boot()
|
||||||
{
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* register
|
* register
|
||||||
@ -49,6 +49,8 @@ class CatchAdminService extends Service
|
|||||||
$this->registerEvents();
|
$this->registerEvents();
|
||||||
$this->registerQuery();
|
$this->registerQuery();
|
||||||
$this->registerExceptionHandle();
|
$this->registerExceptionHandle();
|
||||||
|
$this->registerRoutePath();
|
||||||
|
$this->registerServices();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -113,7 +115,9 @@ class CatchAdminService extends Service
|
|||||||
*/
|
*/
|
||||||
protected function registerEvents(): void
|
protected function registerEvents(): void
|
||||||
{
|
{
|
||||||
$this->app->event->listenEvents(config('catch.events'));
|
$this->app->event->listenEvents([
|
||||||
|
'RouteLoaded' => [LoadModuleRoutes::class]
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -143,4 +147,43 @@ class CatchAdminService extends Service
|
|||||||
{
|
{
|
||||||
$this->app->bind(Handle::class, CatchExceptionHandle::class);
|
$this->app->bind(Handle::class, CatchExceptionHandle::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册模块服务
|
||||||
|
*
|
||||||
|
* @time 2020年06月23日
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function registerServices()
|
||||||
|
{
|
||||||
|
$services = CatchAdmin::getEnabledService();
|
||||||
|
|
||||||
|
foreach ($services as $service) {
|
||||||
|
if (class_exists($service)) {
|
||||||
|
$this->app->register($service);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册路由地址
|
||||||
|
*
|
||||||
|
* @time 2020年06月23日
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function registerRoutePath()
|
||||||
|
{
|
||||||
|
$this->app->instance('routePath', new class {
|
||||||
|
protected $path = [];
|
||||||
|
public function loadRouterFrom($path)
|
||||||
|
{
|
||||||
|
$this->path[] = $path;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
public function get()
|
||||||
|
{
|
||||||
|
return $this->path;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user