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\KeyValueStore
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 | 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; } |
Please login to continue.