只有已启用插件才能执行 route 和 middleware

This commit is contained in:
Edward Yang 2023-02-06 11:44:38 +08:00
parent 76e45fd16e
commit 4d6c89cf6c
2 changed files with 6 additions and 4 deletions

View File

@ -156,6 +156,7 @@ class DesignService
private static function handleRichText($content): array
{
$content['data'] = $content['text'][locale()] ?? '';
return $content;
}

View File

@ -45,17 +45,18 @@ class PluginServiceProvider extends ServiceProvider
$this->pluginBasePath = base_path('plugins');
foreach ($plugins as $plugin) {
$pluginCode = $plugin->getDirname();
$this->bootPlugin($plugin);
$this->registerRoutes($pluginCode);
$this->registerMiddleware($pluginCode);
}
$allPlugins = $manager->getPlugins();
foreach ($allPlugins as $plugin) {
$pluginCode = $plugin->getDirname();
$this->loadMigrations($pluginCode);
$this->loadRoutes($pluginCode);
$this->loadViews($pluginCode);
$this->loadTranslations($pluginCode);
$this->registerMiddleware($pluginCode);
}
}
@ -90,11 +91,11 @@ class PluginServiceProvider extends ServiceProvider
}
/**
* 加载插件路由
* 加载插件路由并注册
*
* @param $pluginCode
*/
private function loadRoutes($pluginCode)
private function registerRoutes($pluginCode)
{
$pluginBasePath = $this->pluginBasePath;
$shopRoutePath = "{$pluginBasePath}/{$pluginCode}/Routes/shop.php";