You are here

function yamlform_update_8076 in YAML Form 8

Issue #2834572: Refactor and improve token management.

File

./yamlform.install, line 223
Install, update and uninstall functions for the YAML Form module.

Code

function yamlform_update_8076() {
  $config_factory = \Drupal::configFactory();

  // Update 'yamlform.settings' configuration.
  $settings_config = \Drupal::configFactory()
    ->getEditable('yamlform.settings');
  $yaml = Yaml::encode($settings_config
    ->getRawData());
  $yaml = str_replace('[yamlform_submission:', '[yamlform_submission:', $yaml);
  $settings_config
    ->setData(Yaml::decode($yaml));
  $settings_config
    ->save();

  // Update 'yamlform.yamlform.*' configuration.
  foreach ($config_factory
    ->listAll('yamlform.yamlform.') as $yamlform_config_name) {
    $yamlform_config = $config_factory
      ->getEditable($yamlform_config_name);
    $yaml = Yaml::encode($yamlform_config
      ->getRawData());
    $yaml = str_replace('[yamlform_submission:', '[yamlform_submission:', $yaml);
    $yamlform_config
      ->setData(Yaml::decode($yaml));
    $yamlform_config
      ->save();
  }
}