function Registry::reset

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

Invalidates theme registry caches.

To be called when the list of enabled extensions is changed.

File

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

Class

Registry
Defines the theme registry service.

Namespace

Drupal\Core\Theme

Code

public function reset() {
    // Reset the runtime registry.
    foreach ($this->runtimeRegistry as $runtime_registry) {
        $runtime_registry->clear();
    }
    $this->runtimeRegistry = [];
    $this->registry = [];
    // Installing and uninstalling themes doesn't invalidate caches because
    // rendered output varies by theme, however the tabs on the appearance page
    // depend on the theme list, so invalidate those via the local tasks cache
    // tag.
    Cache::invalidateTags([
        'local_task',
    ]);
    $cids = [
        'theme_registry:build:modules',
    ];
    foreach ($this->themeHandler
        ->listInfo() as $theme_name => $info) {
        $cids[] = 'theme_registry:' . $theme_name;
        $cids[] = 'theme_registry:runtime:' . $theme_name;
    }
    $this->cache
        ->deleteMultiple($cids);
    if ($this->runtimeCache) {
        $this->runtimeCache
            ->deleteMultiple($cids);
    }
    return $this;
}

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