function CacheTagsChecksumTrait::invalidateTags

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Cache/CacheTagsChecksumTrait.php \Drupal\Core\Cache\CacheTagsChecksumTrait::invalidateTags()
  2. 8.9.x core/lib/Drupal/Core/Cache/CacheTagsChecksumTrait.php \Drupal\Core\Cache\CacheTagsChecksumTrait::invalidateTags()
  3. 10 core/lib/Drupal/Core/Cache/CacheTagsChecksumTrait.php \Drupal\Core\Cache\CacheTagsChecksumTrait::invalidateTags()

Implements \Drupal\Core\Cache\CacheTagsInvalidatorInterface::invalidateTags()

File

core/lib/Drupal/Core/Cache/CacheTagsChecksumTrait.php, line 58

Class

CacheTagsChecksumTrait
A trait for cache tag checksum implementations.

Namespace

Drupal\Core\Cache

Code

public function invalidateTags(array $tags) {
  foreach ($tags as $key => $tag) {
    if (isset($this->invalidatedTags[$tag])) {
      unset($tags[$key]);
    }
    else {
      $this->invalidatedTags[$tag] = TRUE;
      unset($this->tagCache[$tag]);
    }
  }
  if (!$tags) {
    return;
  }
  $in_transaction = $this->getDatabaseConnection()
    ->inTransaction();
  if ($in_transaction) {
    if (empty($this->delayedTags)) {
      $this->getDatabaseConnection()
        ->transactionManager()
        ->addPostTransactionCallback([
        $this,
        'rootTransactionEndCallback',
      ]);
    }
    $this->delayedTags = Cache::mergeTags($this->delayedTags, $tags);
  }
  else {
    $this->doInvalidateTags($tags);
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.