W3cubDocs

/Drupal 8

protected function 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 383

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;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Extension!ThemeHandler.php/function/ThemeHandler::doGetBaseThemes/8.1.x