- Issue created by @owenbush
The helper module kindly offers an easy way to set the default theme for a site, but not a kind and helpful way to set the admin theme for a site. It would be great to offer the equivalent of setDefault() and isDefault() for the admin theme.
Something like so:
/**
* Sets the admin theme.
*
* @param string $theme_name
* Theme name.
*
* @return bool
* TRUE if the admin theme was updated, or FALSE if the requested theme
* was already the admin.
*/
public function setAdmin(string $theme_name): bool {
if (!$this->themeHandler->themeExists($theme_name)) {
$this->themeInstaller->install([$theme_name]);
}
if (!$this->isAdmin($theme_name)) {
$this->configFactory->getEditable('system.theme')->set('admin', $theme_name)->save();
$this->themeManager->resetActiveTheme();
return TRUE;
}
return FALSE;
}
Active
1.0
Code