function webform_update_8099 in Webform 8.5
Same name and namespace in other branches
- 6.x includes/webform.install.update.inc \webform_update_8099()
Issue #2888862: Provide a mechanism to lock a webform submission.
File
- includes/
webform.install.update.inc, line 1877 - Archived Webform update hooks.
Code
function webform_update_8099() {
// Copied from: node_update_8001()
//
// Install the definition that this field had in
// \Drupal\webform\Entity\WebformSubmission::baseFieldDefinitions()
// at the time that this update function was written. If/when code is
// deployed that changes that definition, the corresponding module must
// implement an update function that invokes
// \Drupal::entityDefinitionUpdateManager()->updateFieldStorageDefinition()
// with the new definition.
$storage_definition = BaseFieldDefinition::create('boolean')
->setLabel(t('Locked'))
->setDescription(t('A flag that indicates a locked webform submission.'))
->setDefaultValue(FALSE);
\Drupal::entityDefinitionUpdateManager()
->installFieldStorageDefinition('locked', 'webform_submission', 'webform', $storage_definition);
// Set default value.
\Drupal::database()
->update('webform_submission')
->fields([
'locked' => 0,
])
->execute();
// Add submission locked message to admin and webform settings.
_webform_update_admin_settings();
_webform_update_webform_settings();
}