public EntityStorageBase::save(EntityInterface $entity)
Saves the entity permanently.
\Drupal\Core\Entity\EntityInterface $entity: The entity to save.
SAVED_NEW or SAVED_UPDATED is returned depending on the operation performed.
\Drupal\Core\Entity\EntityStorageException In case of failures, an exception is thrown.
Overrides EntityStorageInterface::save
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; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!EntityStorageBase.php/function/EntityStorageBase::save/8.1.x