function webform_update_8071 in Webform 6.x
Same name and namespace in other branches
- 8.5 includes/webform.install.update.inc \webform_update_8071()
Issue #2898424: Improve Remote Post.
File
- includes/
webform.install.update.inc, line 1424 - Archived Webform update hooks.
Code
function webform_update_8071() {
$settings_mapping = [
'insert_url' => 'completed_url',
'insert_custom_data' => 'completed_custom_data',
'update_url' => 'updated_url',
'update_custom_data' => 'updated_custom_data',
'delete_url' => 'deleted_url',
'delete_custom_data' => 'deleted_custom_data',
];
/** @var \Drupal\webform\WebformInterface[] $webforms */
$webforms = Webform::loadMultiple();
foreach ($webforms as $webform) {
$has_remote_post = FALSE;
$handlers = $webform
->getHandlers();
foreach ($handlers as $handler) {
if ($handler instanceof RemotePostWebformHandler) {
$has_remote_post = TRUE;
$configuration = $handler
->getSettings();
foreach ($configuration as $key => $value) {
if (isset($settings_mapping[$key])) {
$configuration[$settings_mapping[$key]] = $value;
unset($configuration[$key]);
}
}
$configuration += $handler
->defaultConfiguration();
$handler
->getSettings($configuration);
}
}
if ($has_remote_post) {
$webform
->save();
}
}
}