function ThemeInitialization::loadActiveTheme

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Theme/ThemeInitialization.php \Drupal\Core\Theme\ThemeInitialization::loadActiveTheme()
  2. 9 core/lib/Drupal/Core/Theme/ThemeInitialization.php \Drupal\Core\Theme\ThemeInitialization::loadActiveTheme()
  3. 8.9.x core/lib/Drupal/Core/Theme/ThemeInitialization.php \Drupal\Core\Theme\ThemeInitialization::loadActiveTheme()

File

core/lib/Drupal/Core/Theme/ThemeInitialization.php, line 129

Class

ThemeInitialization
Provides the theme initialization logic.

Namespace

Drupal\Core\Theme

Code

public function loadActiveTheme(ActiveTheme $active_theme) {
  // Initialize the theme.
  if ($active_theme->getEngine()) {
    // Include the engine.
    include_once $this->root . '/' . $active_theme->getOwner();
    foreach (array_reverse($active_theme->getBaseThemeExtensions()) as $base) {
      $base->load();
    }
    $active_theme->getExtension()
      ->load();
  }
  else {
    // Include non-engine theme files
    foreach (array_reverse($active_theme->getBaseThemeExtensions()) as $base) {
      // Include the theme file or the engine.
      if ($base->owner) {
        include_once $this->root . '/' . $base->owner;
      }
    }
    // And our theme gets one too.
    if ($active_theme->getOwner()) {
      include_once $this->root . '/' . $active_theme->getOwner();
    }
  }
  // Always include Twig as the default theme engine.
  include_once $this->root . '/core/themes/engines/twig/twig.engine';
}

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