public KeyValueEntityStorage::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 EntityStorageBase::save
File
- core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php, line 151
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 14 | public function save(EntityInterface $entity ) { $id = $entity ->id(); if ( $id === NULL || $id === '' ) { throw new EntityMalformedException( 'The entity does not have an ID.' ); } // Check the entity ID length. // @todo This is not config-specific, but serial IDs will likely never hit // this limit. Consider renaming the exception class. if ( strlen ( $entity ->id()) > static ::MAX_ID_LENGTH) { throw new ConfigEntityIdLengthException( "Entity ID {$entity->id()} exceeds maximum allowed length of " . static ::MAX_ID_LENGTH . ' characters.' ); } return parent::save( $entity ); } |
Please login to continue.