diff --git a/comment_notify.install b/comment_notify.install index 2d0017e..36da8e0 100644 --- a/comment_notify.install +++ b/comment_notify.install @@ -138,16 +138,27 @@ function comment_notify_update_8002() { function comment_notify_update_8100() { $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', ]; + + // Work out which content types to enable. + // @todo Finish this. + foreach ($config->get('bundle_types') as $content_type) { + $vars[$content_type] = 'node--' . $content_type . '--comment'; + } + + // Update the settings. foreach ($vars as $old => $new) { $value = $config->get($old); $config->set($new, $value); $config->clear($old); } + $config->save(); } diff --git a/comment_notify.module b/comment_notify.module index a325681..55ed9f2 100644 --- a/comment_notify.module +++ b/comment_notify.module @@ -415,7 +415,6 @@ function _comment_notify_mailalert(CommentInterface $comment) { } $raw_values = $config->get('mail_templates.watcher.' . $entity->getEntityTypeId()); - kint($raw_values); $token_data = ['comment' => $comment, 'comment-subscribed' => $alert]; if ($entity_type == 'node') { $token_data['node'] = $entity; @@ -482,8 +481,9 @@ function comment_notify_get_unsubscribe_url(CommentInterface $comment) { function comment_notify_entity_extra_field_info() { module_load_include('inc', 'comment_notify', 'comment_notify'); $extras = array(); + $config = \Drupal::config('comment_notify.settings'); - foreach (\Drupal::config('comment_notify.settings')->get('bundle_types') as $bundle_type) { + foreach ($config->get('bundle_types') as $bundle_type) { $field_identifier = explode('--', $bundle_type); $comment_field = FieldConfig::loadByName($field_identifier[0], $field_identifier[1], $field_identifier[2]); if ($comment_field) { diff --git a/config/install/comment_notify.settings.yml b/config/install/comment_notify.settings.yml index 1c86dd7..dbd4827 100644 --- a/config/install/comment_notify.settings.yml +++ b/config/install/comment_notify.settings.yml @@ -1,5 +1,5 @@ bundle_types: - - article + - node--article--comment available_alerts: 1: true 2: true diff --git a/src/Form/CommentNotifySettings.php b/src/Form/CommentNotifySettings.php index b0012ba..5b85fa6 100644 --- a/src/Form/CommentNotifySettings.php +++ b/src/Form/CommentNotifySettings.php @@ -219,7 +219,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { 'comment', 'node', 'user' ], ]; - kint($form['mail_templates']['watcher'][$entity_type]['body']); + return parent::buildForm($form, $form_state); }