Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Core/Theme/Registry.php \Drupal\Core\Theme\Registry::get()
  2. 9 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 238

Class

Registry
Defines the theme registry service.

Namespace

Drupal\Core\Theme

Code

public function get() {
  $this
    ->init($this->themeName);
  if ($cached = $this
    ->cacheGet()) {
    return $cached;
  }

  // If called from inside a Fiber, suspend it, this may allow another code
  // path to begin an asynchronous operation before we do the CPU-intensive
  // task of building the theme registry.
  if (\Fiber::getCurrent() !== NULL) {
    \Fiber::suspend();

    // When the Fiber is resumed, check the cache again since it may have been
    // built in the meantime, either in this process or via a different
    // request altogether.
    if ($cached = $this
      ->cacheGet()) {
      return $cached;
    }
  }
  $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()];
}