You are here

function yamlform_update_8034 in YAML Form 8

Issue #2778715: Refactor other elements.

File

includes/yamlform.update.inc, line 753
YAML Form module update hooks.

Code

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

  // 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('#other_option_label', '#other__option_label', $yaml);
    $yaml = str_replace('#other_placeholder', '#other__placeholder', $yaml);
    $yaml = str_replace('#other_description', '#other__description', $yaml);
    $data = Yaml::decode($yaml);
    \Drupal::configFactory()
      ->getEditable($yamlform_config_name)
      ->setData($data)
      ->save();
  }
}