You are here

TomeStaticSuperCacheTagsInvalidator.php in Tome 8

File

modules/tome_static/modules/tome_static_super_cache/src/TomeStaticSuperCacheTagsInvalidator.php
View source
<?php

namespace Drupal\tome_static_super_cache;

use Drupal\Core\Cache\CacheTagsInvalidator;

/**
 * Decorates the core cache tags invalidator to ignore certain tags.
 */
class TomeStaticSuperCacheTagsInvalidator extends CacheTagsInvalidator {

  /**
   * {@inheritdoc}
   */
  public function invalidateTags(array $tags) {
    if (!isset($GLOBALS[SuperStaticCache::FULL_REBUILD_KEY]) && isset($GLOBALS[SuperStaticCache::REBUILD_KEY])) {
      $skip_tags = [
        'http_response',
        'local_task',
      ];
      foreach ($tags as $i => $tag) {
        if (strpos($tag, 'config:system.menu') === 0 || in_array($tag, $skip_tags, TRUE)) {
          unset($tags[$i]);
        }
      }
    }
    if (!empty($tags)) {
      parent::invalidateTags($tags);
    }
  }

}

Classes

Namesort descending Description
TomeStaticSuperCacheTagsInvalidator Decorates the core cache tags invalidator to ignore certain tags.