You are here

public function ThemeHandler::hasUi in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Extension/ThemeHandler.php \Drupal\Core\Extension\ThemeHandler::hasUi()
  2. 10 core/lib/Drupal/Core/Extension/ThemeHandler.php \Drupal\Core\Extension\ThemeHandler::hasUi()

Determines if a theme should be shown in the user interface.

To be shown in the UI the theme has to be installed. If the theme is hidden it will not be shown unless it is the default or admin theme.

Parameters

string $name: The name of the theme to check.

Return value

bool TRUE if the theme should be shown in the UI, FALSE if not.

Overrides ThemeHandlerInterface::hasUi

File

core/lib/Drupal/Core/Extension/ThemeHandler.php, line 214

Class

ThemeHandler
Default theme handler using the config system to store installation statuses.

Namespace

Drupal\Core\Extension

Code

public function hasUi($name) {
  $themes = $this
    ->listInfo();
  if (isset($themes[$name])) {
    if (!empty($themes[$name]->info['hidden'])) {
      $theme_config = $this->configFactory
        ->get('system.theme');
      return $name == $theme_config
        ->get('default') || $name == $theme_config
        ->get('admin');
    }
    return TRUE;
  }
  return FALSE;
}