You are here

public function DefaultPluginManager::clearCachedDefinitions in Service Container 7.2

Same name and namespace in other branches
  1. 7 lib/Drupal/Component/Plugin/DefaultPluginManager.php \Drupal\Core\Plugin\DefaultPluginManager::clearCachedDefinitions()

Clears static and persistent plugin definition caches.

Don't resort to calling \Drupal::cache()->delete() and friends to make Drupal detect new or updated plugin definitions. Always use this method on the appropriate plugin type's plugin manager!

Overrides CachedDiscoveryInterface::clearCachedDefinitions

File

lib/Drupal/Component/Plugin/DefaultPluginManager.php, line 189
Contains \Drupal\Core\Plugin\DefaultPluginManager.

Class

DefaultPluginManager
Base class for plugin managers.

Namespace

Drupal\Core\Plugin

Code

public function clearCachedDefinitions() {
  if ($this->cacheBackend) {
    if ($this->cacheTags) {

      // Use the cache tags to clear the cache.
      Cache::invalidateTags($this->cacheTags);
    }
    else {
      $this->cacheBackend
        ->delete($this->cacheKey);
    }
  }
  $this->definitions = NULL;
}