function Registry::init

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

Initializes a theme with a certain name.

This function does to much magic, so it should be replaced by another services which holds the current active theme information.

Parameters

string $theme_name: (optional) The name of the theme for which to construct the registry.

3 calls to Registry::init()
Registry::get in core/lib/Drupal/Core/Theme/Registry.php
Returns the complete theme registry from cache or rebuilds it.
Registry::getBaseHook in core/lib/Drupal/Core/Theme/Registry.php
Returns the base hook for a given hook suggestion.
Registry::getRuntime in core/lib/Drupal/Core/Theme/Registry.php
Returns the incomplete, runtime theme registry.

File

core/lib/Drupal/Core/Theme/Registry.php, line 208

Class

Registry
Defines the theme registry service.

Namespace

Drupal\Core\Theme

Code

protected function init($theme_name = NULL) {
    if ($this->initialized) {
        return;
    }
    // Unless instantiated for a specific theme, use globals.
    if (!isset($theme_name)) {
        $this->theme = $this->themeManager
            ->getActiveTheme();
    }
    else {
        $this->theme = $this->themeInitialization
            ->getActiveThemeByName($theme_name);
        $this->themeInitialization
            ->loadActiveTheme($this->theme);
    }
}

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