catchAdmin/extend/catcher/ModuleService.php
2020-07-20 17:03:49 +08:00

68 lines
1.8 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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 ]
// +----------------------------------------------------------------------
namespace catcher;
use think\Service;
abstract class ModuleService extends Service
{
abstract public function loadRouteFrom();
/**
* 注册
*
* @time 2020年07月02日
* @return void
*/
public function register()
{
$this->app->make('routePath')->loadRouterFrom($this->loadRouteFrom());
$this->registerEvents();
$this->registerCommands();;
}
/**
* 事件注册
*
* @time 2020年06月24日
* @return void
*/
protected function registerEvents()
{
if (method_exists($this, 'loadEvents')) {
$this->app->event->listenEvents($this->loadEvents());
}
}
/**
* 注册commands
*
* @time 2020年07月02日
* @return void
*/
protected function registerCommands()
{
if (method_exists($this,'loadCommands') && $this->app->runningInConsole()) {
list($namespace, $path) = $this->loadCommands();
if ($this->app->has('catch_console')) {
$catchConsole = $this->app['catch_console'];
$this->commands($catchConsole->setNamespace($namespace)
->path($path)
->commands());
}
}
}
}