protected function FlaggingStorage::doPostSave in Flag 8.4
Performs post save entity processing.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The saved entity.
bool $update: Specifies whether the entity is being updated or created.
Overrides ContentEntityStorageBase::doPostSave
File
- src/
Entity/ Storage/ FlaggingStorage.php, line 142
Class
- FlaggingStorage
- Default SQL flagging storage.
Namespace
Drupal\flag\Entity\StorageCode
protected function doPostSave(EntityInterface $entity, $update) {
parent::doPostSave($entity, $update);
// After updating or creating a flagging, add it to the cached flagging by entity if already in static cache.
if ($entity
->get('global')->value) {
// If the global flags by entity for this entity have already been cached, then add the newly created flagging.
if (isset($this->globalFlagIdsByEntity[$entity
->get('entity_type')->value][$entity
->get('entity_id')->value])) {
$this->globalFlagIdsByEntity[$entity
->get('entity_type')->value][$entity
->get('entity_id')->value][$entity
->get('flag_id')->value] = $entity
->get('flag_id')->value;
}
}
else {
// If the flags by entity for this entity/user have already been cached, then add the newly created flagging.
if (isset($this->flagIdsByEntity[$entity
->get('uid')->target_id][$entity
->get('entity_type')->value][$entity
->get('entity_id')->value])) {
$this->flagIdsByEntity[$entity
->get('uid')->target_id][$entity
->get('entity_type')->value][$entity
->get('entity_id')->value][$entity
->get('flag_id')->value] = $entity
->get('flag_id')->value;
}
}
}