function webform_update_8617 in Webform 6.x
Issue #3171460: Confirmation URLs and Drupal paths - Settings Handlers.
See also
https://www.drupal.org/project/webform/issues/3160378
File
- includes/
webform.install.update.inc, line 4166 - Archived Webform update hooks.
Code
function webform_update_8617() {
// Convert all confirmation URL to Drupal paths.
$config_factory = \Drupal::configFactory();
foreach ($config_factory
->listAll('webform.webform.') as $webform_config_name) {
$webform_config = $config_factory
->getEditable($webform_config_name);
$data = $webform_config
->getRawData();
$has_settings_handler = FALSE;
foreach ($data['handlers'] as &$handler) {
if ($handler['id'] === 'settings') {
$confirmation_url = $handler['settings']['confirmation_url'];
if (strpos($confirmation_url, '/') === 0) {
$handler['settings']['confirmation_url'] = substr($confirmation_url, 1);
$has_settings_handler = TRUE;
}
}
}
if ($has_settings_handler) {
$webform_config
->setData($data);
$webform_config
->save();
}
}
}