ThemeHandler::doGetBaseThemes

protected ThemeHandler::doGetBaseThemes(array $themes, $theme, $used_themes = array())

Finds the base themes for the specific theme.

Parameters

array $themes: An array of available themes.

string $theme: The name of the theme whose base we are looking for.

array $used_themes: (optional) A recursion parameter preventing endless loops. Defaults to an empty array.

Return value

array An array of base themes.

File

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

Class

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

Namespace

Drupal\Core\Extension

Code

protected function doGetBaseThemes(array $themes, $theme, $used_themes = array()) {
  if (!isset($themes[$theme]->info['base theme'])) {
    return array();
  }

  $base_key = $themes[$theme]->info['base theme'];
  // Does the base theme exist?
  if (!isset($themes[$base_key])) {
    return array($base_key => NULL);
  }

  $current_base_theme = array($base_key => $themes[$base_key]->info['name']);

  // Is the base theme itself a child of another theme?
  if (isset($themes[$base_key]->info['base theme'])) {
    // Do we already know the base themes of this theme?
    if (isset($themes[$base_key]->base_themes)) {
      return $themes[$base_key]->base_themes + $current_base_theme;
    }
    // Prevent loops.
    if (!empty($used_themes[$base_key])) {
      return array($base_key => NULL);
    }
    $used_themes[$base_key] = TRUE;
    return $this->doGetBaseThemes($themes, $base_key, $used_themes) + $current_base_theme;
  }
  // If we get here, then this is our parent theme.
  return $current_base_theme;
}
doc_Drupal
2016-10-29 09:47:57
Comments
Leave a Comment

Please login to continue.