Skip to content

Commit 63a8e91

Browse files
committed
テーマの bootstrap が正常に実行されない問題を改善
1 parent 0c00fe3 commit 63a8e91

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

plugins/baser-core/src/BaserCorePlugin.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,10 @@ public function setupThemePlugin(array $themes): void
251251
$path = [];
252252
foreach($themes as $theme) {
253253
$pluginsPath = CorePlugin::path($theme) . 'plugins' . DS;
254+
// path() を実行するとプラグインクラスがコレクションに登録されてしまう
255+
// ここで登録されてしまうと、対象プラグインの bootstrap() が正常に実行されないため
256+
// ここでは一旦削除する。
257+
CorePlugin::getCollection()->remove($theme);
254258
if (!is_dir($pluginsPath)) continue;
255259
$path[] = $pluginsPath;
256260
}
@@ -280,7 +284,16 @@ public function getAvailableThemes(): array
280284
$themes = [];
281285
foreach($sites as $site) {
282286
if ($site->theme) {
283-
if (!CorePlugin::isLoaded($site->theme) && !is_dir(CorePlugin::path($site->theme))) continue;
287+
if (!CorePlugin::isLoaded($site->theme)) {
288+
$pluginPath = CorePlugin::path($site->theme);
289+
// path() を実行するとプラグインクラスがコレクションに登録されてしまう
290+
// ここで登録されてしまうと、対象プラグインの bootstrap() が正常に実行されないため
291+
// ここでは一旦削除する。
292+
CorePlugin::getCollection()->remove($site->theme);
293+
if(!is_dir($pluginPath)) {
294+
continue;
295+
}
296+
}
284297
if(in_array($site->theme, $themes)) continue;
285298
$themes[] = $site->theme;
286299
}

0 commit comments

Comments
 (0)