You are here

public function WebformSubmissionStorage::save in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/WebformSubmissionStorage.php \Drupal\webform\WebformSubmissionStorage::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 SqlContentEntityStorage::save

File

src/WebformSubmissionStorage.php, line 981

Class

WebformSubmissionStorage
Defines the webform submission storage.

Namespace

Drupal\webform

Code

public function save(EntityInterface $entity) {

  // Set serial number using the webform table, this is done outside of the
  // main transaction initialized in parent::save() to reduce blocking
  // concurrent webform submissions for as little time as possible.
  if (!$entity
    ->serial() && !$entity
    ->getWebform()
    ->getSetting('serial_disabled')) {
    $next_serial = $this->entityTypeManager
      ->getStorage('webform')
      ->getSerial($entity
      ->getWebform());
    $entity
      ->set('serial', $next_serial);
  }
  return parent::save($entity);
}