function Helper::isActive
Same name and namespace in other branches
- main core/themes/admin/src/Helper.php \Drupal\admin\Helper::isActive()
Helper function for check if admin is active.
File
-
core/
themes/ admin/ src/ Helper.php, line 203
Class
- Helper
- Admin helper methods.
Namespace
Drupal\adminCode
public static function isActive() : bool {
if (self::$active === NULL) {
// Check if set as admin theme.
$admin_theme_name = \Drupal::config('system.theme')->get('admin');
if ($admin_theme_name === 'admin') {
return TRUE;
}
$theme_handler = \Drupal::service('theme_handler')->listInfo();
// Check if set as frontend theme.
$frontend_theme_name = \Drupal::config('system.theme')->get('default');
// Check if base themes are set.
if (isset($theme_handler[$frontend_theme_name]->base_themes)) {
$frontend_base_themes = $theme_handler[$frontend_theme_name]->base_themes;
}
// Add theme name to base theme array.
$frontend_base_themes[$frontend_theme_name] = $frontend_theme_name;
// Admin theme will have no value if it is set to use the default theme.
if ($admin_theme_name && isset($theme_handler[$admin_theme_name]->base_themes)) {
$admin_base_themes = $theme_handler[$admin_theme_name]->base_themes;
$admin_base_themes[$admin_theme_name] = $admin_theme_name;
}
else {
$admin_base_themes = $frontend_base_themes;
}
$base_themes = array_merge($admin_base_themes, $frontend_base_themes);
self::$active = array_key_exists('admin', $base_themes);
}
return self::$active;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.