class JwPlayerSettingsCacheTag in JW Player 8
Invalidates the 'library_info' cache tag when saving jw_player.settings.
Hierarchy
- class \Drupal\jw_player\EventSubscriber\JwPlayerSettingsCacheTag implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of JwPlayerSettingsCacheTag
1 string reference to 'JwPlayerSettingsCacheTag'
1 service uses JwPlayerSettingsCacheTag
File
- src/
EventSubscriber/ JwPlayerSettingsCacheTag.php, line 18 - Contains \Drupal\jw_player\EventSubscriber\JwPlayerSettingsCacheTag.
Namespace
Drupal\jw_player\EventSubscriberView source
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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
JwPlayerSettingsCacheTag:: |
protected | property | The cache tags invalidator. | |
JwPlayerSettingsCacheTag:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
JwPlayerSettingsCacheTag:: |
public | function | Invalidate the 'library_info' cache tag whenever the settings are modified. | |
JwPlayerSettingsCacheTag:: |
public | function | Constructs a JwPlayerSettingsCacheTag object. |