You are here

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'
jw_player.services.yml in ./jw_player.services.yml
jw_player.services.yml
1 service uses JwPlayerSettingsCacheTag
jw_player.settings_cache_tag in ./jw_player.services.yml
Drupal\jw_player\EventSubscriber\JwPlayerSettingsCacheTag

File

src/EventSubscriber/JwPlayerSettingsCacheTag.php, line 18
Contains \Drupal\jw_player\EventSubscriber\JwPlayerSettingsCacheTag.

Namespace

Drupal\jw_player\EventSubscriber
View 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

Namesort descending Modifiers Type Description Overrides
JwPlayerSettingsCacheTag::$cacheTagsInvalidator protected property The cache tags invalidator.
JwPlayerSettingsCacheTag::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.
JwPlayerSettingsCacheTag::onSave public function Invalidate the 'library_info' cache tag whenever the settings are modified.
JwPlayerSettingsCacheTag::__construct public function Constructs a JwPlayerSettingsCacheTag object.