Move theme localization to the boot process. (#5349)

It appears that doing this in the "register" process can result, at times, in an exception to be thrown as the connection to the DB is not yet established.
This commit is contained in:
Ben Thomson 2020-11-11 09:53:31 +08:00 committed by GitHub
parent 50816a9556
commit 16e0bd4d09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -44,7 +44,6 @@ class ServiceProvider extends ModuleServiceProvider
$this->registerBackendPermissions();
$this->registerBackendWidgets();
$this->registerBackendSettings();
$this->registerBackendLocalization();
}
}
@ -59,6 +58,10 @@ class ServiceProvider extends ModuleServiceProvider
$this->bootMenuItemEvents();
$this->bootRichEditorEvents();
if (App::runningInBackend()) {
$this->bootBackendLocalization();
}
}
/**
@ -303,16 +306,16 @@ class ServiceProvider extends ModuleServiceProvider
}
/**
* Registers localization from an active theme for backend items.
* Boots localization from an active theme for backend items.
*/
protected function registerBackendLocalization()
protected function bootBackendLocalization()
{
$theme = CmsTheme::getActiveTheme();
$langPath = $theme->getPath() . '/lang';
if (File::isDirectory($langPath)) {
Lang::addNamespace("themes.{$theme->getId()}", $langPath);
Lang::addNamespace('themes.' . $theme->getId(), $langPath);
}
}