function EntityBase::invalidateTagsOnSave
Same name in other branches
- 9 core/lib/Drupal/Core/Entity/EntityBase.php \Drupal\Core\Entity\EntityBase::invalidateTagsOnSave()
- 8.9.x core/lib/Drupal/Core/Entity/EntityBase.php \Drupal\Core\Entity\EntityBase::invalidateTagsOnSave()
- 11.x core/lib/Drupal/Core/Entity/EntityBase.php \Drupal\Core\Entity\EntityBase::invalidateTagsOnSave()
Invalidates an entity's cache tags upon save.
Parameters
bool $update: TRUE if the entity has been updated, or FALSE if it has been inserted.
1 call to EntityBase::invalidateTagsOnSave()
- EntityBase::postSave in core/
lib/ Drupal/ Core/ Entity/ EntityBase.php - Acts on a saved entity before the insert or update hook is invoked.
2 methods override EntityBase::invalidateTagsOnSave()
- ConfigEntityBase::invalidateTagsOnSave in core/
lib/ Drupal/ Core/ Config/ Entity/ ConfigEntityBase.php - Override to never invalidate the entity's cache tag; the config system already invalidates it.
- File::invalidateTagsOnSave in core/
modules/ file/ src/ Entity/ File.php - Invalidates an entity's cache tags upon save.
File
-
core/
lib/ Drupal/ Core/ Entity/ EntityBase.php, line 532
Class
- EntityBase
- Defines a base entity class.
Namespace
Drupal\Core\EntityCode
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);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.