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. 10 core/lib/Drupal/Core/Theme/ThemeInitialization.php \Drupal\Core\Theme\ThemeInitialization::loadActiveTheme()
  3. 9 core/lib/Drupal/Core/Theme/ThemeInitialization.php \Drupal\Core\Theme\ThemeInitialization::loadActiveTheme()
  4. 8.9.x core/lib/Drupal/Core/Theme/ThemeInitialization.php \Drupal\Core\Theme\ThemeInitialization::loadActiveTheme()

Loads a theme, so it is ready to be used.

Loading a theme includes loading and initializing the engine, each base theme and its engines.

Parameters

\Drupal\Core\Theme\ActiveTheme $active_theme: The theme to load.

Overrides ThemeInitializationInterface::loadActiveTheme

1 call to ThemeInitialization::loadActiveTheme()
ThemeInitialization::initTheme in core/lib/Drupal/Core/Theme/ThemeInitialization.php
Initializes a given theme.

File

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

Class

ThemeInitialization
Provides the theme initialization logic.

Namespace

Drupal\Core\Theme

Code

public function loadActiveTheme(ActiveTheme $active_theme) {
  // Initialize the theme.
  if ($engine = $active_theme->getEngine()) {
    if (!$this->themeEngines
      ->has($engine) && $active_theme->getOwner() && file_exists($this->root . '/' . $active_theme->getOwner())) {
      @trigger_error(sprintf('Using .engine files for theme engines is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Convert %s.engine to a service. See https://www.drupal.org/node/3547356', $engine), E_USER_DEPRECATED);
      // Include the engine.
      include_once $this->root . '/' . $active_theme->getOwner();
    }
    foreach (array_reverse($active_theme->getBaseThemeExtensions()) as $base) {
      $base->load();
    }
    $active_theme->getExtension()
      ->load();
  }
  // 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.