EntityStorageBase::save

public EntityStorageBase::save(EntityInterface $entity)

Saves the entity permanently.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity to save.

Return value

SAVED_NEW or SAVED_UPDATED is returned depending on the operation performed.

Throws

\Drupal\Core\Entity\EntityStorageException In case of failures, an exception is thrown.

Overrides EntityStorageInterface::save

File

core/lib/Drupal/Core/Entity/EntityStorageBase.php, line 384

Class

EntityStorageBase
A base entity storage class.

Namespace

Drupal\Core\Entity

Code

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;
}
doc_Drupal
2016-10-29 09:07:42
Comments
Leave a Comment

Please login to continue.