update:模块配置加载

This commit is contained in:
JaguarJack 2020-09-26 15:11:50 +08:00
parent 25c5faf440
commit 5ec24ae9c9
2 changed files with 18 additions and 10 deletions

View File

@ -15,18 +15,11 @@ use catcher\ModuleService;
class MonitorService extends ModuleService class MonitorService extends ModuleService
{ {
public function register() protected function loadConfig()
{ {
parent::register(); // TODO: Change the autogenerated stub return require __DIR__ . DIRECTORY_SEPARATOR . 'config.php';
$this->registerConfig();
} }
protected function registerConfig()
{
$this->app->config->set(array_merge($this->app->config->get('catch'),
require __DIR__ . DIRECTORY_SEPARATOR . 'config.php'), 'catch');
}
public function loadRouteFrom() public function loadRouteFrom()
{ {
// TODO: Implement loadRouteFrom() method. // TODO: Implement loadRouteFrom() method.

View File

@ -28,7 +28,9 @@ abstract class ModuleService extends Service
$this->registerEvents(); $this->registerEvents();
$this->registerCommands();; $this->registerCommands();
$this->registerConfig();
} }
/** /**
@ -44,6 +46,19 @@ abstract class ModuleService extends Service
} }
} }
/**
* register config
*
* @time 2020年09月25日
* @return void
*/
protected function registerConfig()
{
if (method_exists($this, 'loadConfig')) {
$this->app->config->set(array_merge($this->app->config->get('catch'), $this->loadConfig()), 'catch');
}
}
/** /**
* 注册commands * 注册commands
* *