You are here

function comment_notify_update_8003 in Comment Notify 8

Update settings for generic entity support.

File

./comment_notify.install, line 133
Comment_notify.install.

Code

function comment_notify_update_8003() {

  /** @var \Drupal\Core\Config\Config $config */
  $config = \Drupal::service('config.factory')
    ->getEditable('comment_notify.settings');

  // Update the email settings.
  $vars = [
    'mail_templates.watcher.subject' => 'mail_templates.watcher.node.subject',
    'mail_templates.watcher.body' => 'mail_templates.watcher.node.body',
    'mail_templates.entity_author.subject' => 'mail_templates.entity_author.node.subject',
    'mail_templates.entity_author.body' => 'mail_templates.entity_author.node.body',
  ];

  // Update the settings.
  foreach ($vars as $old => $new) {
    $value = $config
      ->get($old);
    $config
      ->set($new, $value);
    $config
      ->clear($old);
  }
  $config
    ->save();
}