You are here

protected function ThemeHandler::doGetBaseThemes in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Extension/ThemeHandler.php \Drupal\Core\Extension\ThemeHandler::doGetBaseThemes()

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.

1 call to ThemeHandler::doGetBaseThemes()
ThemeHandler::getBaseThemes in core/lib/Drupal/Core/Extension/ThemeHandler.php
Finds all the base themes for the specified theme.

File

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

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