diff --git a/core/lib/Drupal/Core/Plugin/Discovery/CacheDecorator.php b/core/lib/Drupal/Core/Plugin/Discovery/CacheDecorator.php index 7a57395..50c2c3d 100644 --- a/core/lib/Drupal/Core/Plugin/Discovery/CacheDecorator.php +++ b/core/lib/Drupal/Core/Plugin/Discovery/CacheDecorator.php @@ -8,6 +8,7 @@ namespace Drupal\Core\Plugin\Discovery; use Drupal\Component\Plugin\Discovery\DiscoveryInterface; +use Drupal\Core\Cache\CacheBackendInterface; /** * Enables static and persistent caching of discovered plugin definitions. @@ -29,6 +30,13 @@ class CacheDecorator implements DiscoveryInterface { protected $cacheBin; /** + * The cache tags associated with the definition list. + * + * @var array + */ + protected $cacheTags; + + /** * The plugin definitions of the decorated discovery class. * * @var array @@ -54,10 +62,11 @@ class CacheDecorator implements DiscoveryInterface { * @param string $cache_bin * The cache bin used for storage and retrieval of the definition list. */ - public function __construct(DiscoveryInterface $decorated, $cache_key, $cache_bin = 'cache') { + public function __construct(DiscoveryInterface $decorated, $cache_key, $cache_bin = 'cache', array $cache_tags = array()) { $this->decorated = $decorated; $this->cacheKey = $cache_key; $this->cacheBin = $cache_bin; + $this->cacheTags = $cache_tags; } /** @@ -104,7 +113,7 @@ protected function getCachedDefinitions() { */ protected function setCachedDefinitions($definitions) { if (isset($this->cacheKey)) { - cache($this->cacheBin)->set($this->cacheKey, $definitions); + cache($this->cacheBin)->set($this->cacheKey, $definitions, CacheBackendInterface::CACHE_PERMANENT, $this->cacheTags); } $this->definitions = $definitions; } @@ -115,4 +124,5 @@ protected function setCachedDefinitions($definitions) { public function __call($method, $args) { return call_user_func_array(array($this->decorated, $method), $args); } + }