protected function KeyValueEntityStorage::doSave
protected KeyValueEntityStorage::doSave($id, EntityInterface $entity)
Performs storage-specific saving of the entity.
Parameters
int|string $id: The original entity ID.
\Drupal\Core\Entity\EntityInterface $entity: The entity to save.
Return value
bool|int If the record insert or update failed, returns FALSE. If it succeeded, returns SAVED_NEW or SAVED_UPDATED, depending on the operation performed.
Overrides EntityStorageBase::doSave
File
- core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php, line 169
Class
- KeyValueEntityStorage
- Provides a key value backend for entities.
Namespace
Drupal\Core\Entity\KeyValueStoreCode
protected function doSave($id, EntityInterface $entity) { $is_new = $entity->isNew(); // Save the entity data in the key value store. $this->keyValueStore->set($entity->id(), $entity->toArray()); // If this is a rename, delete the original entity. if ($this->has($id, $entity) && $id !== $entity->id()) { $this->keyValueStore->delete($id); } return $is_new ? SAVED_NEW : SAVED_UPDATED; }
© 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!KeyValueStore!KeyValueEntityStorage.php/function/KeyValueEntityStorage::doSave/8.1.x