public function save(EntityInterface
$entity) { // Track if this entity is new.
$is_new =
$entity->
isNew();
// Execute presave logic and invoke the related hooks.
$id =
$this->
doPreSave($entity);
// Perform the save and reset the static cache for the changed entity.
$return =
$this->
doSave($id,
$entity);
// Execute post save logic and invoke the related hooks.
$this->
doPostSave($entity, !
$is_new);
return $return;
} /**
* Performs presave entity processing.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The saved entity.
*
* @return int|string|null
* The processed entity identifier, or null for new entities.
*
* @throws \Drupal\Core\Entity\EntityStorageException
* If the entity identifier is invalid.
*/