X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fcolor%2Fsrc%2FEventSubscriber%2FColorConfigCacheInvalidator.php;fp=web%2Fcore%2Fmodules%2Fcolor%2Fsrc%2FEventSubscriber%2FColorConfigCacheInvalidator.php;h=46b67a1d230e0ada6783ec5121a011298c666989;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/core/modules/color/src/EventSubscriber/ColorConfigCacheInvalidator.php b/web/core/modules/color/src/EventSubscriber/ColorConfigCacheInvalidator.php new file mode 100644 index 000000000..46b67a1d2 --- /dev/null +++ b/web/core/modules/color/src/EventSubscriber/ColorConfigCacheInvalidator.php @@ -0,0 +1,56 @@ +cacheTagsInvalidator = $cache_tags_invalidator; + } + + /** + * Invalidate cache tags when a color theme config object changes. + * + * @param \Drupal\Core\Config\ConfigCrudEvent $event + * The Event to process. + */ + public function onChange(ConfigCrudEvent $event) { + // Changing a theme's color settings causes the theme's asset library + // containing the color CSS file to be altered to use a different file. + if (strpos($event->getConfig()->getName(), 'color.theme.') === 0) { + $this->cacheTagsInvalidator->invalidateTags(['library_info']); + } + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() { + $events[ConfigEvents::SAVE][] = ['onChange']; + $events[ConfigEvents::DELETE][] = ['onChange']; + + return $events; + } + +}