function ThemeManager::initTheme

Same name in other branches
  1. 9 core/lib/Drupal/Core/Theme/ThemeManager.php \Drupal\Core\Theme\ThemeManager::initTheme()
  2. 10 core/lib/Drupal/Core/Theme/ThemeManager.php \Drupal\Core\Theme\ThemeManager::initTheme()
  3. 11.x core/lib/Drupal/Core/Theme/ThemeManager.php \Drupal\Core\Theme\ThemeManager::initTheme()

Initializes the active theme for a given route match.

Parameters

\Drupal\Core\Routing\RouteMatchInterface $route_match: The current route match.

1 call to ThemeManager::initTheme()
ThemeManager::getActiveTheme in core/lib/Drupal/Core/Theme/ThemeManager.php
Returns the active theme object.

File

core/lib/Drupal/Core/Theme/ThemeManager.php, line 396

Class

ThemeManager
Provides the default implementation of a theme manager.

Namespace

Drupal\Core\Theme

Code

protected function initTheme(RouteMatchInterface $route_match = NULL) {
    // Determine the active theme for the theme negotiator service. This includes
    // the default theme as well as really specific ones like the ajax base theme.
    if (!$route_match) {
        $route_match = \Drupal::routeMatch();
    }
    if ($route_match instanceof StackedRouteMatchInterface) {
        $route_match = $route_match->getMasterRouteMatch();
    }
    $theme = $this->themeNegotiator
        ->determineActiveTheme($route_match);
    $this->activeTheme = $this->themeInitialization
        ->initTheme($theme);
}

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