function webform_update_8601 in Webform 6.x
Issue #3106961: [Webform 8.x-6.x] Improve token naming conventions.
File
- includes/
webform.install.update.inc, line 3956 - Archived Webform update hooks.
Code
function webform_update_8601() {
$config_factory = \Drupal::configFactory();
foreach ($config_factory
->listAll('webform.webform.') as $webform_config_name) {
$webform_config = $config_factory
->getEditable($webform_config_name);
$yaml = Yaml::encode($webform_config
->getRawData());
if (strpos($yaml, '[webform_submission:view-url') !== FALSE || strpos($yaml, '[webform_submission:update-url') !== FALSE || strpos($yaml, '[webform_submission:delete-url') !== FALSE) {
$yaml = str_replace('[webform_submission:view-url', '[webform_submission:token-view-url', $yaml);
$yaml = str_replace('[webform_submission:update-url', '[webform_submission:token-update-url', $yaml);
$yaml = str_replace('[webform_submission:delete-url', '[webform_submission:token-delete-url', $yaml);
$webform_config
->setData(Yaml::decode($yaml));
$webform_config
->save();
}
}
}