You are here

public function ThemeInitialization::loadActiveTheme in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 134
Contains \Drupal\Core\Theme\ThemeInitialization.

Class

ThemeInitialization
Provides the theme initialization logic.

Namespace

Drupal\Core\Theme

Code

public function loadActiveTheme(ActiveTheme $active_theme) {

  // Initialize the theme.
  if ($theme_engine = $active_theme
    ->getEngine()) {

    // Include the engine.
    include_once $this->root . '/' . $active_theme
      ->getOwner();
    if (function_exists($theme_engine . '_init')) {
      foreach ($active_theme
        ->getBaseThemes() as $base) {
        call_user_func($theme_engine . '_init', $base
          ->getExtension());
      }
      call_user_func($theme_engine . '_init', $active_theme
        ->getExtension());
    }
  }
  else {

    // include non-engine theme files
    foreach ($active_theme
      ->getBaseThemes() as $base) {

      // Include the theme file or the engine.
      if ($base
        ->getOwner()) {
        include_once $this->root . '/' . $base
          ->getOwner();
      }
    }

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