function Registry::get

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

Returns the complete theme registry from cache or rebuilds it.

Return value

array The complete theme registry data array.

See also

Registry::$registry

File

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

Class

Registry
Defines the theme registry service.

Namespace

Drupal\Core\Theme

Code

public function get() {
    $this->init($this->themeName);
    if (isset($this->registry[$this->theme
        ->getName()])) {
        return $this->registry[$this->theme
            ->getName()];
    }
    if ($cache = $this->cache
        ->get('theme_registry:' . $this->theme
        ->getName())) {
        $this->registry[$this->theme
            ->getName()] = $cache->data;
    }
    else {
        $this->build();
        // Only persist it if all modules are loaded to ensure it is complete.
        if ($this->moduleHandler
            ->isLoaded()) {
            $this->setCache();
        }
    }
    return $this->registry[$this->theme
        ->getName()];
}

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