catchAdmin/extend/catcher/ModuleService.php

66 lines
1.8 KiB
PHP
Raw Normal View History

2020-06-24 08:47:46 +08:00
<?php
// +----------------------------------------------------------------------
// | CatchAdmin [Just Like ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
// +----------------------------------------------------------------------
// | Author: JaguarJack [ njphper@gmail.com ]
// +----------------------------------------------------------------------
2020-06-24 09:11:30 +08:00
namespace catcher;
use think\Service;
abstract class ModuleService extends Service
{
abstract public function loadRouteFrom();
2020-07-02 14:01:05 +08:00
/**
* 注册
*
* @time 2020年07月02日
* @return void
*/
2020-06-24 09:11:30 +08:00
public function register()
{
$this->app->make('routePath')->loadRouterFrom($this->loadRouteFrom());
$this->registerEvents();
2020-07-02 14:01:05 +08:00
$this->registerCommands();;
2020-06-24 09:11:30 +08:00
}
/**
2020-07-02 14:01:05 +08:00
* 事件注册
2020-06-24 09:11:30 +08:00
*
* @time 2020年06月24日
* @return void
*/
protected function registerEvents()
{
if (method_exists($this, 'loadEvents')) {
$this->app->event->listenEvents($this->loadEvents());
}
}
2020-07-02 14:01:05 +08:00
/**
* 注册commands
*
* @time 2020年07月02日
* @return void
*/
protected function registerCommands()
{
if (method_exists($this,'loadCommands')) {
list($namespace, $path) = $this->loadCommands();
2020-06-24 09:11:30 +08:00
$catchConsole = $this->app['catch_console'];
$this->commands($catchConsole->setNamespace($namespace)
->path($path)
->commands());
2020-07-02 14:01:05 +08:00
}
}
2020-06-24 09:11:30 +08:00
}