function ToolbarThemeHooks::libraryInfoAlter
Same name and namespace in other branches
- 11.x core/modules/toolbar/src/Hook/ToolbarThemeHooks.php \Drupal\toolbar\Hook\ToolbarThemeHooks::libraryInfoAlter()
Implements hook_library_info_alter().
Attributes
#[Hook('library_info_alter')]
File
-
core/
modules/ toolbar/ src/ Hook/ ToolbarThemeHooks.php, line 146
Class
- ToolbarThemeHooks
- Hook implementations for toolbar.
Namespace
Drupal\toolbar\HookCode
public function libraryInfoAlter(&$libraries, $extension) : void {
if ($extension !== 'toolbar') {
return;
}
$admin_theme = $this->configFactory
->get('system.theme')
->get('admin');
$active_theme = $this->themeManager
->getActiveTheme()
->getName();
if ($active_theme === $admin_theme) {
return;
}
$overrides = [
'claro' => [
'toolbar' => [
'component' => [
'css/toolbar.module.css' => 'components/toolbar.module.css',
],
'theme' => [
'css/toolbar.theme.css' => 'theme/toolbar.theme.css',
'css/toolbar.icons.theme.css' => 'theme/toolbar.icons.theme.css',
],
],
'toolbar.menu' => [
'state' => [
'css/toolbar.menu.css' => 'state/toolbar.menu.css',
],
],
],
'default_admin' => [
'toolbar' => [
'theme' => [
'css/toolbar.theme.css' => 'theme/toolbar.theme.css',
'css/toolbar.icons.theme.css' => 'theme/toolbar.icons.theme.css',
],
],
'toolbar.menu' => [
'state' => [
'css/toolbar.menu.css' => 'state/toolbar.menu.css',
],
],
],
];
if (!isset($overrides[$admin_theme])) {
return;
}
$path_prefix = '/core/modules/toolbar/css/' . $admin_theme . '/';
foreach ($overrides[$admin_theme] as $library => $concerns) {
foreach ($concerns as $concern => $replacements) {
foreach ($replacements as $original => $replacement) {
$config = $libraries[$library]['css'][$concern][$original];
$libraries[$library]['css'][$concern][$path_prefix . $replacement] = $config;
unset($libraries[$library]['css'][$concern][$original]);
}
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.