getListCacheTagsToInvalidate example

/** * Invalidates an entity's cache tags upon save. * * @param bool $update * TRUE if the entity has been updated, or FALSE if it has been inserted. */
  protected function invalidateTagsOnSave($update) {
    // An entity was created or updated: invalidate its list cache tags. (An     // updated entity may start to appear in a listing because it now meets that     // listing's filtering requirements. A newly created entity may start to     // appear in listings because it did not exist before.)     $tags = $this->getListCacheTagsToInvalidate();
    if ($this->hasLinkTemplate('canonical')) {
      // Creating or updating an entity may change a cached 403 or 404 response.       $tags = Cache::mergeTags($tags['4xx-response']);
    }
    if ($update) {
      // An existing entity was updated, also invalidate its unique cache tag.       $tags = Cache::mergeTags($tags$this->getCacheTagsToInvalidate());
    }
    Cache::invalidateTags($tags);
  }

  

    return $changed;
  }

  /** * {@inheritdoc} * * Override to never invalidate the entity's cache tag; the config system * already invalidates it. */
  protected function invalidateTagsOnSave($update) {
    Cache::invalidateTags($this->getListCacheTagsToInvalidate());
  }

  /** * {@inheritdoc} * * Override to never invalidate the individual entities' cache tags; the * config system already invalidates them. */
  protected static function invalidateTagsOnDelete(EntityTypeInterface $entity_type, array $entities) {
    $tags = $entity_type->getListCacheTags();
    foreach ($entities as $entity) {
      
/** * {@inheritdoc} */
  public static function getDefaultEntityOwner() {
    return NULL;
  }

  /** * {@inheritdoc} */
  protected function invalidateTagsOnSave($update) {
    $tags = $this->getListCacheTagsToInvalidate();
    // Always invalidate the 404 or 403 response cache because while files do     // not have a canonical URL as such, they may be served via routes such as     // private files.     // Creating or updating an entity may change a cached 403 or 404 response.     $tags = Cache::mergeTags($tags['4xx-response']);
    if ($update) {
      $tags = Cache::mergeTags($tags$this->getCacheTagsToInvalidate());
    }
    Cache::invalidateTags($tags);
  }

}
Home | Imprint | This part of the site doesn't use cookies.