You are here

protected function WebformEncryptSubmissionStorage::doPreSave in Webform Encrypt 8

Performs presave entity processing.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The saved entity.

Return value

int|string The processed entity identifier.

Throws

\Drupal\Core\Entity\EntityStorageException If the entity identifier is invalid.

Overrides WebformSubmissionStorage::doPreSave

File

src/WebformEncryptSubmissionStorage.php, line 242

Class

WebformEncryptSubmissionStorage
Alter webform submission storage definitions.

Namespace

Drupal\webform_encrypt

Code

protected function doPreSave(EntityInterface $entity) {

  /** @var \Drupal\webform\WebformSubmissionInterface $entity */
  $id = parent::doPreSave($entity);
  $data_original = $entity
    ->getData();
  $webform = $entity
    ->getWebform();
  $encrypted_data = $this
    ->encryptElements($data_original, $webform);
  $entity
    ->setData($encrypted_data);
  return $id;
}