JwPlayerSettingsCacheTag.php in JW Player 8
Namespace
Drupal\jw_player\EventSubscriberFile
src/EventSubscriber/JwPlayerSettingsCacheTag.phpView source
<?php
/**
* @file
* Contains \Drupal\jw_player\EventSubscriber\JwPlayerSettingsCacheTag.
*/
namespace Drupal\jw_player\EventSubscriber;
use Drupal\Core\Cache\CacheTagsInvalidatorInterface;
use Drupal\Core\Config\ConfigCrudEvent;
use Drupal\Core\Config\ConfigEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* Invalidates the 'library_info' cache tag when saving jw_player.settings.
*/
class JwPlayerSettingsCacheTag implements EventSubscriberInterface {
/**
* The cache tags invalidator.
*
* @var \Drupal\Core\Cache\CacheTagsInvalidatorInterface
*/
protected $cacheTagsInvalidator;
/**
* Constructs a JwPlayerSettingsCacheTag object.
*
* @param \Drupal\Core\Cache\CacheTagsInvalidatorInterface $cache_tags_invalidator
* The cache tags invalidator.
*/
public function __construct(CacheTagsInvalidatorInterface $cache_tags_invalidator) {
$this->cacheTagsInvalidator = $cache_tags_invalidator;
}
/**
* Invalidate the 'library_info' cache tag whenever the settings are modified.
*
* @param \Drupal\Core\Config\ConfigCrudEvent $event
* The Event to process.
*/
public function onSave(ConfigCrudEvent $event) {
if ($event
->getConfig()
->getName() === 'jw_player.settings') {
// Invalidate caches, so new libraries are created.
$this->cacheTagsInvalidator
->invalidateTags(array(
'library_info',
));
}
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[ConfigEvents::SAVE][] = [
'onSave',
];
return $events;
}
}
Classes
Name | Description |
---|---|
JwPlayerSettingsCacheTag | Invalidates the 'library_info' cache tag when saving jw_player.settings. |