You are here

public function WebformEncryptSubmissionStorage::encryptChildren in Webform Encrypt 8

Helper function to recursively encrypt children of fields.

Parameters

array $data: Element data by reference.

\Drupal\encrypt\EncryptionProfileInterface $encryption_profile: The encryption profile to be used on this element.

Throws

\Drupal\encrypt\Exception\EncryptException

1 call to WebformEncryptSubmissionStorage::encryptChildren()
WebformEncryptSubmissionStorage::encryptElements in src/WebformEncryptSubmissionStorage.php
Helper function to recursively encrypt fields.

File

src/WebformEncryptSubmissionStorage.php, line 120

Class

WebformEncryptSubmissionStorage
Alter webform submission storage definitions.

Namespace

Drupal\webform_encrypt

Code

public function encryptChildren(array &$data, EncryptionProfileInterface $encryption_profile) {
  foreach ($data as $key => $value) {
    if (is_array($value)) {
      $this
        ->encryptChildren($data[$key], $encryption_profile);
    }
    else {
      $encrypted_value = $this
        ->encrypt($value, $encryption_profile);
      $data[$key] = $encrypted_value;
    }
  }
}