function File::invalidateTagsOnSave

Same name and namespace in other branches
  1. 9 core/modules/file/src/Entity/File.php \Drupal\file\Entity\File::invalidateTagsOnSave()
  2. 10 core/modules/file/src/Entity/File.php \Drupal\file\Entity\File::invalidateTagsOnSave()

Overrides EntityBase::invalidateTagsOnSave

File

core/modules/file/src/Entity/File.php, line 287

Class

File
Defines the file entity class.

Namespace

Drupal\file\Entity

Code

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);
}

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