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()
|
|
|
|
|
{
|
2020-07-19 08:46:12 +08:00
|
|
|
|
if (method_exists($this,'loadCommands') && $this->app->runningInConsole()) {
|
2020-07-02 14:01:05 +08:00
|
|
|
|
list($namespace, $path) = $this->loadCommands();
|
2020-06-24 09:11:30 +08:00
|
|
|
|
|
2020-07-21 08:01:20 +08:00
|
|
|
|
if ($this->app->has('catch\console')) {
|
|
|
|
|
$catchConsole = $this->app['catch\console'];
|
2020-07-02 14:22:02 +08:00
|
|
|
|
|
2020-07-20 17:03:49 +08:00
|
|
|
|
$this->commands($catchConsole->setNamespace($namespace)
|
|
|
|
|
->path($path)
|
|
|
|
|
->commands());
|
|
|
|
|
}
|
2020-07-02 14:01:05 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-06-24 09:11:30 +08:00
|
|
|
|
|
|
|
|
|
}
|