public function SqlContentEntityStorage::save in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php \Drupal\Core\Entity\Sql\SqlContentEntityStorage::save()
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
1 call to SqlContentEntityStorage::save()
- MediaStorage::save in core/
modules/ media/ src/ MediaStorage.php - Saves the entity permanently.
1 method overrides SqlContentEntityStorage::save()
- MediaStorage::save in core/
modules/ media/ src/ MediaStorage.php - Saves the entity permanently.
File
- core/
lib/ Drupal/ Core/ Entity/ Sql/ SqlContentEntityStorage.php, line 834
Class
- SqlContentEntityStorage
- A content entity database storage implementation.
Namespace
Drupal\Core\Entity\SqlCode
public function save(EntityInterface $entity) {
$transaction = $this->database
->startTransaction();
try {
$return = parent::save($entity);
// Ignore replica server temporarily.
\Drupal::service('database.replica_kill_switch')
->trigger();
return $return;
} catch (\Exception $e) {
$transaction
->rollBack();
watchdog_exception($this->entityTypeId, $e);
throw new EntityStorageException($e
->getMessage(), $e
->getCode(), $e);
}
}