function webform_encrypt_update_8102 in Webform Encrypt 8
Update existing encrypted data.
File
- ./
webform_encrypt.install, line 103 - Contains install and update related functions for the Webform Encrypt module.
Code
function webform_encrypt_update_8102() {
$submissions = \Drupal::database()
->select('webform_submission_data', 'wsd')
->fields('wsd', [])
->execute()
->fetchAll();
foreach ($submissions as $submission) {
$webform = Webform::load($submission->webform_id);
$config = $webform
->getThirdPartySetting('webform_encrypt', 'element');
if (!empty($config[$submission->name])) {
$encrypted_data = [
'data' => $submission->value,
'encrypt_profile' => $config[$submission->name]['encrypt_profile'],
];
\Drupal::database()
->update('webform_submission_data')
->fields([
'value' => serialize($encrypted_data),
])
->condition('sid', $submission->sid)
->condition('name', $submission->name)
->condition('property', $submission->property)
->condition('delta', $submission->delta)
->execute();
}
}
}