function ThemeExtensionList::fillInSubThemeData

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Extension/ThemeExtensionList.php \Drupal\Core\Extension\ThemeExtensionList::fillInSubThemeData()
  2. 8.9.x core/lib/Drupal/Core/Extension/ThemeExtensionList.php \Drupal\Core\Extension\ThemeExtensionList::fillInSubThemeData()
  3. 10 core/lib/Drupal/Core/Extension/ThemeExtensionList.php \Drupal\Core\Extension\ThemeExtensionList::fillInSubThemeData()

Fills in data for themes that are also sub-themes.

Parameters

array $themes: The array of partly processed theme information.

array $sub_themes: A list of themes from the $theme array that are also sub-themes.

1 call to ThemeExtensionList::fillInSubThemeData()
ThemeExtensionList::doList in core/lib/Drupal/Core/Extension/ThemeExtensionList.php
Builds the list of extensions.

File

core/lib/Drupal/Core/Extension/ThemeExtensionList.php, line 172

Class

ThemeExtensionList
Provides a list of available themes.

Namespace

Drupal\Core\Extension

Code

protected function fillInSubThemeData(array &$themes, array $sub_themes) {
    foreach ($sub_themes as $name) {
        $sub_theme = $themes[$name];
        // The $base_themes property is optional; only set for sub themes.
        // @see ThemeHandlerInterface::listInfo()
        $sub_theme->base_themes = $this->doGetBaseThemes($themes, $name);
        // empty() cannot be used here, since static::doGetBaseThemes() adds
        // the key of a base theme with a value of NULL in case it is not found,
        // in order to prevent needless iterations.
        if (!current($sub_theme->base_themes)) {
            continue;
        }
        // Determine the root base theme.
        $root_key = key($sub_theme->base_themes);
        // Build the list of sub-themes for each of the theme's base themes.
        foreach (array_keys($sub_theme->base_themes) as $base_theme) {
            $themes[$base_theme]->sub_themes[$name] = $sub_theme->info['name'];
        }
        // Add the theme engine info from the root base theme.
        if (isset($themes[$root_key]->owner)) {
            $sub_theme->info['engine'] = $themes[$root_key]->info['engine'];
            $sub_theme->owner = $themes[$root_key]->owner;
            $sub_theme->prefix = $themes[$root_key]->prefix;
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.