class CachedDiscoveryClearer

Same name in this branch
  1. 11.x core/lib/Drupal/Core/ProxyClass/Plugin/CachedDiscoveryClearer.php \Drupal\Core\ProxyClass\Plugin\CachedDiscoveryClearer
Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/ProxyClass/Plugin/CachedDiscoveryClearer.php \Drupal\Core\ProxyClass\Plugin\CachedDiscoveryClearer
  2. 9 core/lib/Drupal/Core/Plugin/CachedDiscoveryClearer.php \Drupal\Core\Plugin\CachedDiscoveryClearer
  3. 8.9.x core/lib/Drupal/Core/ProxyClass/Plugin/CachedDiscoveryClearer.php \Drupal\Core\ProxyClass\Plugin\CachedDiscoveryClearer
  4. 8.9.x core/lib/Drupal/Core/Plugin/CachedDiscoveryClearer.php \Drupal\Core\Plugin\CachedDiscoveryClearer
  5. 10 core/lib/Drupal/Core/ProxyClass/Plugin/CachedDiscoveryClearer.php \Drupal\Core\ProxyClass\Plugin\CachedDiscoveryClearer
  6. 10 core/lib/Drupal/Core/Plugin/CachedDiscoveryClearer.php \Drupal\Core\Plugin\CachedDiscoveryClearer

Defines a class which is capable of clearing the cache on plugin managers.

Hierarchy

Expanded class hierarchy of CachedDiscoveryClearer

File

core/lib/Drupal/Core/Plugin/CachedDiscoveryClearer.php, line 11

Namespace

Drupal\Core\Plugin
View source
class CachedDiscoveryClearer implements CachedDiscoveryClearerInterface {
    
    /**
     * The legacy stored discoveries.
     *
     * @var \Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface[]
     *
     * @deprecated in drupal:11.1.0 and is removed from drupal:12.0.0. Pass
     *    the full set of services to the constructor instead.
     * @see https://www.drupal.org/node/3442229
     */
    protected $legacyCachedDiscoveries = [];
    
    /**
     * Adds a plugin manager to the active list.
     *
     * @param \Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface $cached_discovery
     *   An object that implements the cached discovery interface, typically a
     *   plugin manager.
     *
     * @deprecated in drupal:11.1.0 and is removed from drupal:12.0.0. Pass
     *   the full set of services to the constructor instead.
     * @see https://www.drupal.org/node/3442229
     */
    public function addCachedDiscovery(CachedDiscoveryInterface $cached_discovery) {
        @trigger_error('The ' . __METHOD__ . ' method is deprecated in drupal:11.1.0 and is removed from drupal:12.0.0. Pass the full set of services to the constructor instead. See https://www.drupal.org/node/3442229', E_USER_DEPRECATED);
        $this->legacyCachedDiscoveries[] = $cached_discovery;
    }
    
    /**
     * Constructs the CachedDiscoveryClearer service.
     *
     * @param \Traversable $cachedDiscoveries
     *   The cached discoveries.
     */
    public function __construct(\Traversable $cachedDiscoveries) {
    }
    
    /**
     * {@inheritdoc}
     */
    public function clearCachedDefinitions() {
        foreach ($this->cachedDiscoveries as $cached_discovery) {
            $cached_discovery->clearCachedDefinitions();
        }
        // @phpstan-ignore property.deprecated
        foreach ($this->legacyCachedDiscoveries as $cached_discovery) {
            $cached_discovery->clearCachedDefinitions();
        }
    }

}

Members

Title Sort descending Deprecated Modifiers Object type Summary Overriden Title
CachedDiscoveryClearer::$legacyCachedDiscoveries Deprecated protected property The legacy stored discoveries.
CachedDiscoveryClearer::addCachedDiscovery Deprecated public function Adds a plugin manager to the active list.
CachedDiscoveryClearer::clearCachedDefinitions public function Clears the cache on all cached discoveries. Overrides CachedDiscoveryClearerInterface::clearCachedDefinitions
CachedDiscoveryClearer::__construct public function Constructs the CachedDiscoveryClearer service.

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