diff --git a/comment_notify.inc b/comment_notify.inc
index 17632a2..abfa6bb 100644
--- a/comment_notify.inc
+++ b/comment_notify.inc
@@ -5,6 +5,7 @@
  *
  * Contains functions which utilize the database and other internal helpers.
  */
+use Drupal\comment\CommentInterface;
 
 /**
  * Get the notification preferences for a specific user.
@@ -22,8 +23,8 @@ function comment_notify_get_user_notification_setting($uid) {
     // Handle anonymous users with defaults.
     if ($uid == 0) {
       $users[0] = new stdClass();
-      $users[0]->comment_notify = comment_notify_variable_registry_get('default_registered_mailalert');
-      $users[0]->node_notify = comment_notify_variable_registry_get('node_notify_default_mailalert');
+      $users[0]->comment_notify = \Drupal::config('comment_notify.settings')->get('enable_default.watcher');
+      $users[0]->node_notify = \Drupal::config('comment_notify.settings')->get('enable_default.entity_author');
     }
     else {
       $setting = db_select('comment_notify_user_settings', 'cnus')
@@ -45,8 +46,8 @@ function comment_notify_get_user_notification_setting($uid) {
 
 function comment_notify_get_default_notification_setting() {
   return (object) array(
-    'comment_notify' => comment_notify_variable_registry_get('default_registered_mailalert'),
-    'node_notify' => comment_notify_variable_registry_get('node_notify_default_mailalert')
+    'comment_notify' => \Drupal::config('comment_notify.settings')->get('enable_default.watcher'),
+    'node_notify' => \Drupal::config('comment_notify.settings')->get('enable_default.entity_author')
   );
 }
 
@@ -188,15 +189,16 @@ function comment_notify_get_notification_type($cid) {
  * Get a list of mails which need to be contacted for a node.
  *
  * @param integer $nid
- * @return QueryStatement
+ * @return \Drupal\comment\CommentInterface[]
+ *   A list of comment entities.
  */
 function comment_notify_get_watchers($nid) {
-  $cids = db_query("SELECT c.cid FROM {comment} c INNER JOIN {comment_notify} cn ON c.cid = cn.cid LEFT JOIN {users} u ON c.uid = u.uid WHERE c.nid = :nid AND c.status = :status AND cn.notify <> :notify AND (u.uid = 0 OR u.status = 1)", array(
+  $cids = db_query("SELECT c.cid FROM {comment_field_data} c INNER JOIN {comment_notify} cn ON c.cid = cn.cid LEFT JOIN {users_field_data} u ON c.uid = u.uid WHERE c.entity_id = :nid AND c.status = :status AND cn.notify <> :notify AND (u.uid = 0 OR u.status = 1)", array(
     ':nid' => $nid,
-    ':status' => COMMENT_PUBLISHED,
+    ':status' => CommentInterface::PUBLISHED,
     ':notify' => COMMENT_NOTIFY_DISABLED,
   ))->fetchCol();
-  return comment_load_multiple($cids);
+  return \Drupal::entityManager()->getStorage('comment')->loadMultiple($cids);
 }
 
 /**
@@ -214,7 +216,7 @@ function comment_notify_mark_comment_as_notified($comment) {
     ->fields(array(
       'notified' => 1,
     ))
-    ->condition('cid', $comment->cid)
+    ->condition('cid', $comment->id())
     ->execute();
 }
 
@@ -231,12 +233,12 @@ function comment_notify_unsubscribe_by_email($mail) {
   $update_query = db_update('comment_notify');
   $update_query->fields(array('notify' => 0));
 
-  $comment_query = db_select('comment', 'c');
+  $comment_query = db_select('comment_field_data', 'c');
   $comment_query->fields('c', array('cid'));
 
-  $uid = db_select('users', 'u')
-    ->fields('u', array('uid'))
-    ->condition('mail', $mail)
+  $uid = db_select('users_field_data', 'u')
+    ->fields('u', ['uid'])
+    ->condition('mail', $mail, '=')
     ->execute()
     ->fetchField();
   if ($uid) {
@@ -297,42 +299,3 @@ function comment_notify_unsubscribe_by_hash($hash) {
     ->execute();
   }
 }
-
-/**
- * Helper function to centralize variable management and defaults.
- *
- * All variables fall under the "comment_notify" psuedo namespace.  This ensures
- * consistancy, and eliminates some verbosity in the calling code.  In addition
- * by storing all of the variables in one place, we avoid repeating duplicate
- * defaults which are harder to maintain.
- *
- * @param string $name
- * @return mixed
- */
-function comment_notify_variable_registry_get($name) {
-  $variables = array();
-  $variables['author_subject'] = t('[site:name] :: new comment for your post.');
-  $variables['available_alerts'] = array(COMMENT_NOTIFY_NODE, COMMENT_NOTIFY_COMMENT);
-  $variables['default_anon_mailalert'] = COMMENT_NOTIFY_NODE;
-  $variables['node_notify_default_mailtext'] = AUTHOR_MAILTEXT;
-  $variables['default_registered_mailalert'] = COMMENT_NOTIFY_DISABLED;
-  $variables['node_notify_default_mailalert'] = 0;
-  $variables['watcher_subject'] = '[site:name] :: new comment on [comment:node:title]';
-  $variables['comment_notify_default_mailtext'] = DEFAULT_MAILTEXT;
-  $variables['node_types'] = array('article' => 'article');
-
-  // Errors
-  $variables['error_anonymous_email_missing'] = 'If you want to subscribe to comments you must supply a valid e-mail address.';
-  return variable_get("comment_notify_" . $name, $variables[$name]);
-}
-
-/**
- * Helper function to centralize setting variables.
- *
- * @param string $name
- * @param mixed $value
- * @return boolean
- */
-function comment_notify_variable_registry_set($name, $value) {
-  return variable_set("comment_notify_" . $name, $value);
-}
diff --git a/comment_notify.info b/comment_notify.info
deleted file mode 100644
index 594c053..0000000
--- a/comment_notify.info
+++ /dev/null
@@ -1,12 +0,0 @@
-name = Comment Notify
-description = "Comment follow-up e-mail notification for anonymous as well as registered users."
-dependencies[] = comment
-dependencies[] = token
-core = 7.x
-configure = admin/config/people/comment_notify
-files[] = comment_notify.install
-files[] = comment_notify.module
-files[] = comment_notify.migrate.inc
-files[] = comment_notify.tokens.inc
-files[] = comment_notify.inc
-files[] = comment_notify.test
diff --git a/comment_notify.info.yml b/comment_notify.info.yml
new file mode 100644
index 0000000..eebce01
--- /dev/null
+++ b/comment_notify.info.yml
@@ -0,0 +1,8 @@
+name: 'Comment Notify'
+description: 'Comment follow-up e-mail notification for anonymous as well as registered users.'
+configure: comment_notify.settings
+dependencies:
+  - comment
+  - token
+core: 8.x
+type: module
diff --git a/comment_notify.install b/comment_notify.install
index fe18281..f221bbb 100644
--- a/comment_notify.install
+++ b/comment_notify.install
@@ -10,36 +10,23 @@
 function comment_notify_install() {
 
   // Create entries for existing comments.
-
-  $comments_select = db_select('comment', 'c');
-  $comments_select->join('users', 'u', 'c.uid = u.uid');
+  $comments_select = db_select('comment_field_data', 'c');
+  $comments_select->join('users_field_data', 'u', 'c.uid = u.uid');
   $comments_select->addField('c', 'cid');
   $comments_select->addExpression('0', 'notify');
   // Mix in a random string to all values.
   $salt = uniqid(mt_rand(), TRUE);
   if (db_driver() == 'pgsql') {
-    $comments_select->addExpression("MD5(:salt || c.mail || COALESCE(u.mail, u.init) || c.uid || c.name || c.nid || c.hostname || c.cid)", 'notify_hash', array(':salt' => $salt));
+    $comments_select->addExpression("MD5(:salt || c.mail || COALESCE(u.mail, u.init) || c.uid || c.name || c.entity_id || c.hostname || c.cid)", 'notify_hash', array(':salt' => $salt));
   }
   else {
-    $comments_select->addExpression("MD5(CONCAT(:salt, c.mail, COALESCE(u.mail, u.init), c.uid, c.name, c.nid, c.hostname, c.cid))", 'notify_hash', array(':salt' => $salt));
+    $comments_select->addExpression("MD5(CONCAT_WS('', :salt, c.mail, COALESCE(u.mail, u.init), c.uid, c.name, c.entity_id, c.hostname, c.cid))", 'notify_hash', array(':salt' => $salt));
   }
 
+  \Drupal::logger('the_shit')->debug((string) $comments_select);
+
   // Set module weight low so that other modules act on the comment first.
   db_insert('comment_notify')->from($comments_select)->execute();
-  db_update('system')->
-    fields(array(
-    'weight' => 10
-    ))
-    ->condition('name', 'comment_notify');
-}
-
-/**
- * Implements hook_uninstall().
- */
-function comment_notify_uninstall() {
-  variable_del('node_notify_default_mailtext');
-  db_delete('variable')
-    ->where('name', "comment_notify_%", 'LIKE');
 }
 
 /**
@@ -107,78 +94,3 @@ function comment_notify_schema() {
 
   return $schema;
 }
-
-/**
- * Head 2 head update for the new size of the hash field.
- */
-function comment_notify_update_7002() {
-  $new_spec = array(
-    'type' => 'varchar',
-    'description' => 'A hash of unique information about the commenter.  Used for unsubscribing users.',
-    'length' => '128',
-    'not null' => TRUE,
-    'default' => ''
-  );
-  $keys = array(
-    'indexes' => array('notify_hash' => array('notify_hash')),
-  );
-  db_drop_index('comment_notify', 'notify_hash');
-  db_change_field('comment_notify', 'notify_hash', 'notify_hash', $new_spec, $keys);
-}
-
-/**
- * Fix tokens in comment subscriber e-mail template.
- */
-function comment_notify_update_7003() {
-  $variables = array(
-    'comment_notify_author_subject' => 'author',
-    'comment_notify_node_notify_default_mailtext' => 'author',
-    'comment_notify_watcher_subject' => 'commenter',
-    'comment_notify_comment_notify_default_mailtext' => 'commenter',
-  );
-  foreach ($variables as $variable => $context) {
-    // If the variable is using the default value, this will return NULL and we
-    // can skip it.
-    if ($text = variable_get($variable)) {
-      $replacements = array(
-        '[comment:unsubscribe-url]' => '[comment-subscribed:unsubscribe-url]',
-        '[comment:name]' => '[comment:author]',
-        '[node:' => '[comment:node:', // Replace all node tokens with comment:node.
-      );
-      if ($context == 'author') {
-        $replacements['[user:name]'] = '[comment:node:author]';
-        $replacements['[user:'] = '[comment:node:author:';
-      }
-      elseif ($context == 'commenter') {
-        $replacements['[user:name]'] = '[comment-subscribed:author]';
-        $replacements['[user:'] = '[comment-subscribed:author:';
-      }
-      $text = strtr($text, $replacements);
-      variable_set($variable, $text);
-    }
-  }
-  return 'Comment Notify token strings updated.';
-}
-
-/**
- * Fix a missing default causes warnings for Postgresql and some MySQL.
- */
-function comment_notify_update_7004() {
-  db_change_field('comment_notify', 'notified', 'notified',  array('type' => 'int', 'size' => 'small', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
-}
-
-/**
- * Fix minor schema inconsistencies caused by the last update.
- */
-function comment_notify_update_7005() {
-  // Previous update altered size and unsigned unnecessarily.
-  $notified_field = array(
-    'type' => 'int',
-    'description' => 'A boolean indicator for whether or not a notification for the comment has been sent: 1 means yes, 0 means no.',
-    'size' => 'tiny',
-    'not null' => TRUE,
-    'default' => 0,
-    'disp-width' => '11',
-  );
-  db_change_field('comment_notify', 'notified', 'notified', $notified_field);
-}
diff --git a/comment_notify.libraries.yml b/comment_notify.libraries.yml
new file mode 100644
index 0000000..6f25349
--- /dev/null
+++ b/comment_notify.libraries.yml
@@ -0,0 +1,12 @@
+comment_notify:
+  version: 1.x
+  css:
+    theme:
+      comment_notify.css: {}
+
+comment_notify.type-selector:
+  version: 1.x
+  js:
+    comment_notify.js: {}
+  dependencies:
+    - core/jquery
diff --git a/comment_notify.links.menu.yml b/comment_notify.links.menu.yml
new file mode 100644
index 0000000..633ab2e
--- /dev/null
+++ b/comment_notify.links.menu.yml
@@ -0,0 +1,5 @@
+comment_notify.settings:
+  route_name: comment_notify.settings
+  title: 'Comment notification'
+  description: 'Configure settings for e-mails about new comments.'
+  parent: user.admin_index
diff --git a/comment_notify.links.task.yml b/comment_notify.links.task.yml
new file mode 100644
index 0000000..d6367c4
--- /dev/null
+++ b/comment_notify.links.task.yml
@@ -0,0 +1,9 @@
+comment_notify.settings:
+  route_name: comment_notify.settings
+  title: Settings
+  base_route: comment_notify.settings
+comment_notify.unsubscribe:
+  route_name: comment_notify.unsubscribe
+  title: Unsubscribe
+  weight: 2
+  base_route: comment_notify.settings
diff --git a/comment_notify.module b/comment_notify.module
index 1c79aa1..d107038 100644
--- a/comment_notify.module
+++ b/comment_notify.module
@@ -6,68 +6,27 @@
  * This module provides comment follow-up e-mail notification for anonymous and registered users.
  */
 
+use Drupal\comment\CommentInterface;
+use Drupal\Component\Utility\Html;
+use Drupal\Component\Utility\Unicode;
+use Drupal\Core\Entity\EntityInterface;
+use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\Language\LanguageInterface;
+use Drupal\field\Entity\FieldConfig;
+use Drupal\node\Entity\NodeType;
+use Drupal\user\UserInterface;
+
 define('COMMENT_NOTIFY_DISABLED', 0);
 define('COMMENT_NOTIFY_NODE', 1);
 define('COMMENT_NOTIFY_COMMENT', 2);
 
-
-define('AUTHOR_MAILTEXT',
-'Hi [comment:node:author],
-
-You have received a comment on: "[comment:node:title]"
-
-----
-[comment:title]
-[comment:body]
-----
-
-You can view the comment at the following url
-[comment:url]
-
-You will receive emails like this for all replies to your posts. You can
-disable this by logging in and changing the settings on your user account at
-[comment:node:author:edit-url].
-
--- [site:name] team
-[site:url]');
-
-define('DEFAULT_MAILTEXT',
-'Hi [comment-subscribed:author],
-
-[comment:author] has commented on: "[comment:node:title]"
-
-----
-[comment:title]
-[comment:body]
-----
-
-You can view the comment at the following url
-[comment:url]
-
-You can stop receiving emails when someone replies to this post,
-by going to [comment-subscribed:unsubscribe-url]
-
-You can set up auto-following feature for all future posts
-by creating your own user with a few clicks here [site:login-url]
-
--- [site:name] team
-[site:url]');
-
-
 /**
- * Implements hook_init().
+ * Implements hook_page_attachments().
  */
-function comment_notify_init() {
-  // Add on every page - they are both very small so it's better to add
-  // everywhere than force a second file on some pages.
-  $options = array('every_page' => TRUE);
-  $path = drupal_get_path('module', 'comment_notify');
-  drupal_add_css($path . '/comment_notify.css', $options);
-
-  // We only add the JS if more than one subscription mode is enabled.
-  $available_options = _comment_notify_options();
-  if (count($available_options) > 1) {
-    drupal_add_js($path . '/comment_notify.js', $options);
+function comment_notify_page_attachments(array &$attachments) {
+  $attachments['#attached']['library'][] = 'comment_notify/comment_notify';
+  if (count(_comment_notify_options()) > 1) {
+    $attachments['#attached']['library'][] = 'comment_notify/comment_notify.type-selector';
   }
 }
 
@@ -80,34 +39,31 @@ function _comment_notify_options() {
     COMMENT_NOTIFY_COMMENT  => t('Replies to my comment')
   );
 
-  $available_options = array();
-  $options = variable_get('comment_notify_available_alerts', drupal_map_assoc(array(COMMENT_NOTIFY_NODE, COMMENT_NOTIFY_COMMENT)));
-  foreach ($options as $key => $available) {
-    if ($key == $available) {
-      $available_options[$available] = $total_options[$available];
-    }
-  }
+  $selected_options = array_filter(\Drupal::config('comment_notify.settings')->get('available_alerts'));
+  $available_options = array_intersect_key($total_options, $selected_options);
 
   return $available_options;
 }
 
 
-function comment_notify_form_comment_form_alter(&$form, &$form_state, $form_id) {
-  global $user;
-  if (!(user_access('subscribe to comments') || user_access('administer comments'))) {
+function comment_notify_form_comment_form_alter(&$form, FormStateInterface $form_state, $form_id) {
+  $user = \Drupal::currentUser();
+  if (!(\Drupal::currentUser()->hasPermission('subscribe to comments') || \Drupal::currentUser()->hasPermission('administer comments'))) {
     return;
   }
 
+  /** @var \Drupal\Core\Entity\EntityInterface $commented_entity */
+  $commented_entity = $form_state->getFormObject()->getEntity()->getCommentedEntity();
+
   // Only add the checkbox if this is an enabled content type
-  $node = node_load($form['nid']['#value'] ? $form['nid']['#value'] : $form['nid']['#default_value']);
-  $enabled_types = variable_get('comment_notify_node_types', drupal_map_assoc(array($node->type)));
-  if (empty($enabled_types[$node->type])) {
+  $enabled_types = \Drupal::config('comment_notify.settings')->get('node_types');
+  if (!in_array($commented_entity->bundle(), $enabled_types)) {
     return;
   }
 
   $available_options = _comment_notify_options();
   // Add the checkbox for anonymous users.
-  if ($user->uid == 0) {
+  if ($user->isAnonymous()) {
     // If anonymous users can't enter their e-mail don't tempt them with the checkbox.
     if (empty($form['author']['mail'])) {
       return;
@@ -115,115 +71,57 @@ function comment_notify_form_comment_form_alter(&$form, &$form_state, $form_id)
     $form['#validate'][] = 'comment_notify_comment_validate';
   }
   module_load_include('inc', 'comment_notify', 'comment_notify');
-  $preference = comment_notify_get_user_comment_notify_preference($user->uid);
+  $preference = comment_notify_get_user_comment_notify_preference($user->id());
 
   // If you want to hide this on your site see http://drupal.org/node/322482
-  $form['notify_settings']['notify'] = array(
+  $form['comment_notify_settings']['notify'] = array(
     '#type' => 'checkbox',
     '#title' => t('Notify me when new comments are posted'),
     '#default_value' => (bool) $preference,
   );
 
-  $form['notify_settings']['notify_type'] = array(
+  $form['comment_notify_settings']['notify_type'] = array(
     '#type' => 'radios',
     '#options' => $available_options,
     '#default_value' => $preference ? $preference : 1,
   );
   if (count($available_options) == 1) {
-    $form['notify_settings']['notify_type']['#type'] = 'hidden';
-    $form['notify_settings']['notify_type']['#value'] = key($available_options);
+    $form['comment_notify_settings']['notify_type']['#type'] = 'hidden';
+    $form['comment_notify_settings']['notify_type']['#value'] = key($available_options);
   }
 
   // If this is an existing comment we set the default value based on their selection last time.
-  if ($form['cid']['#value'] != '') {
-    $notify = comment_notify_get_notification_type($form['cid']['#value']);
-    $form['notify_settings']['notify']['#default_value'] = (bool) $notify;
+  /** @var \Drupal\comment\CommentInterface $comment */
+  $comment = $form_state->getFormObject()->getEntity();
+  if (!$comment->isNew()) {
+    $notify = comment_notify_get_notification_type($comment->id());
+    $form['comment_notify_settings']['notify']['#default_value'] = (bool) $notify;
     if (count($available_options) > 1) {
-      $form['notify_settings']['notify_type']['#default_value'] = empty($notify) ? COMMENT_NOTIFY_NODE : $notify;
+      $form['comment_notify_settings']['notify_type']['#default_value'] = empty($notify) ? COMMENT_NOTIFY_NODE : $notify;
     }
     else {
-      $form['notify_settings']['notify_type']['#default_value'] = key($available_options);
+      $form['comment_notify_settings']['notify_type']['#default_value'] = key($available_options);
     }
   }
-}
-
-/**
- * Implements hook_permission().
- */
-function comment_notify_permission() {
-  return array(
-    'administer comment notify' => array(
-      'title' => 'Administer Comment Notify',
-      'description' => 'Change global comment notification settings.',
-  ),
-    'subscribe to comments' => array(
-      'title' => 'Subscribe to comment notifications',
-      'description' => 'Subscribe to recieve notifications when new comments are posted.',
-  ),
-  );
-}
-
-/**
- * Implements hook_menu().
- */
-function comment_notify_menu() {
-
-  $items['admin/config/people/comment_notify'] = array(
-    'title' => 'Comment Notify',
-    'description' => 'Configure settings for e-mails about new comments.',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('comment_notify_settings'),
-    'access arguments' => array('administer comment notify'),
-    'type' => MENU_NORMAL_ITEM,
-  );
-  $items['admin/config/people/comment_notify/settings'] = array(
-    'title' => 'Settings',
-    'description' => 'Configure settings for e-mails about new comments.',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('comment_notify_settings'),
-    'access arguments' => array('administer comment notify'),
-    'type' => MENU_DEFAULT_LOCAL_TASK,
-  );
-
-  $items['admin/config/people/comment_notify/unsubscribe'] = array(
-    'title' => 'Unsubscribe',
-    'description' => 'Unsubscribe an email from all notifications.',
-    'weight' => 2,
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('comment_notify_unsubscribe'),
-    'access arguments' => array('administer comment notify'),
-    'type' => MENU_LOCAL_TASK,
-  );
-  $items['comment_notify/disable/%'] = array(
-    'title' => 'Disable comment notification',
-    'page callback' => 'comment_notify_disable_page',
-    'page arguments' => array(2),
-    'access arguments' => array('access content'),
-    'type' => MENU_CALLBACK
-  );
 
-  return $items;
+  // Make sure the notify pseudofields are included when the entity is built.
+  $form['#entity_builders'][] = '_comment_notify_form_build_comment_entity';
 }
 
 /**
- * Page callback to allow users to unsubscribe simply by visiting the page.
+ * Entity builder for the comment form.
  */
-function comment_notify_disable_page($hash) {
-  module_load_include('inc', 'comment_notify', 'comment_notify');
-  if (comment_notify_unsubscribe_by_hash($hash)) {
-    return(t('Your comment follow-up notification for this post was disabled. Thanks.'));
-  }
-  else {
-    return(t('Sorry, there was a problem unsubscribing from notifications.'));
-  }
+function _comment_notify_form_build_comment_entity($entity_type_id, EntityInterface $entity, array &$form, FormStateInterface $form_state) {
+  $entity->notify = $form_state->getValue('notify');
+  $entity->notify_type = $form_state->getValue('notify_type');
 }
 
-function comment_notify_comment_validate($comment) {
-  global $user;
+function comment_notify_comment_validate(&$form, FormStateInterface $form_state) {
+  $user = \Drupal::currentUser();
   // We assume that if they are non-anonymous then they have a valid mail.
   // For anonymous users, though, we verify that they entered a mail and let comment.module validate it is real.
-  if (!$user->uid && $comment['notify_settings']['notify']['#value'] && empty($comment['author']['mail']['#value'])) {
-    form_set_error('mail', t('If you want to subscribe to comments you must supply a valid e-mail address.'));
+  if ($user->isAnonymous() && $form['notify_settings']['notify']['#value'] && empty($form['author']['mail']['#value'])) {
+    $form_state->setErrorByName('mail', t('If you want to subscribe to comments you must supply a valid e-mail address.'));
   }
 }
 
@@ -233,9 +131,9 @@ function comment_notify_comment_publish($comment) {
 }
 
 /**
- * Implements hook_comment_update().
+ * Implements hook_ENTITY_TYPE_update() for comment.
  */
-function comment_notify_comment_update($comment) {
+function comment_notify_comment_update(CommentInterface $comment) {
   module_load_include('inc', 'comment_notify', 'comment_notify');
 
   // Take the status of the "notify" checkbox if they unchecked it.
@@ -247,10 +145,10 @@ function comment_notify_comment_update($comment) {
   }
   // In case they have changed their status, save it in the database.
   if (isset($status)) {
-    comment_notify_update_notification($comment->cid, $status);
+    comment_notify_update_notification($comment->id(), $status);
   }
   // And send notifications - the real purpose of the module.
-  if ($comment->status == COMMENT_PUBLISHED) {
+  if ($comment->isPublished()) {
     _comment_notify_mailalert($comment);
   }
 
@@ -259,84 +157,81 @@ function comment_notify_comment_update($comment) {
 /**
  * Implements hook_comment_insert().
  */
-function comment_notify_comment_insert($comment) {
+function comment_notify_comment_insert(\Drupal\comment\CommentInterface $comment) {
   module_load_include('inc', 'comment_notify', 'comment_notify');
 
-  global $user;
+  $user = \Drupal::currentUser();
   // For new comments, we first build up a string to be used as the identifier for the alert.
   // This identifier is used to later unsubscribe the user or allow them to
   // potentially edit their comment / preferences if they are anonymous.
   // The string is built with token and their host and comment identifier.
   // It is stored and referenced, we really just need something unique/unguessable.
-  $hostname = isset($comment->hostname) ? $comment->hostname : (isset($user->hostname) ? $user->hostname : '');
-  $notify_hash = drupal_get_token($hostname . $comment->cid);
+  $hostname = !$comment->getHostname() ? $comment->getHostname() : (isset($user->hostname) ? $user->hostname : '');
+  $notify_hash = \Drupal::csrfToken()->get($hostname . $comment->id());
 
   if (!empty($comment->notify)) {
     $notify = $comment->notify_type;
     // If they don't have a preference, save one.
-    $current = comment_notify_get_user_comment_notify_preference($user->uid);
-    if ($current == 0 && $user->uid) {
-      comment_notify_set_user_notification_setting($user->uid, NULL, $comment->notify_type);
+    $current = comment_notify_get_user_comment_notify_preference($user->id());
+    if ($current == 0 && $user->id()) {
+      comment_notify_set_user_notification_setting($user->id(), NULL, $comment->notify_type);
     }
   }
   else {
     $notify = 0;
   }
   // And then save the data.
-  comment_notify_add_notification($comment->cid, $notify, $notify_hash);
+  comment_notify_add_notification($comment->id(), $notify, $notify_hash);
 
   // And send notifications - the real purpose of the module.
-  if ($comment->status == COMMENT_PUBLISHED) {
+  if ($comment->isPublished() == CommentInterface::PUBLISHED) {
     _comment_notify_mailalert($comment);
   }
 }
 
-function comment_notify_comment_delete($comment) {
+function comment_notify_comment_delete(\Drupal\comment\CommentInterface $comment) {
   module_load_include('inc', 'comment_notify', 'comment_notify');
-  comment_notify_remove_all_notifications($comment->cid);
+  comment_notify_remove_all_notifications($comment->id());
 }
 
 
 /**
  * Implement hook_form_alter().
  */
-function comment_notify_form_alter(&$form, &$form_state, $form_id) {
+function comment_notify_form_alter(&$form, \Drupal\Core\Form\FormStateInterface &$form_state, $form_id) {
   module_load_include('inc', 'comment_notify', 'comment_notify');
 
-  if (!($form_id == 'user_register_form' || $form_id == 'user_profile_form')) {
-    return;
-  }
-  elseif ($form['#user_category'] != 'account') {
+  if (!($form_id == 'user_register_form' || $form_id == 'user_form')) {
     return;
   }
 
-  $user = $form['#user'];
+  $user = $form_state->getFormObject()->getEntity();
   if (!empty($user->comment_notify_settings)) {
     $node_notify = $user->comment_notify_settings->node_notify;
     $comment_notify = $user->comment_notify_settings->comment_notify;
   }
 
   $form['comment_notify_settings'] = array(
-    '#type' => 'fieldset',
+    '#type' => 'details',
     '#title' => t('Comment follow-up notification settings'),
     '#weight' => 4,
-    '#collapsible' => TRUE
+    '#open' => TRUE,
   );
 
   // Only show the node followup UI if the user has permission to create nodes.
   $nodes = FALSE;
   foreach (node_type_get_names() as $type => $name) {
-    if (node_access('create', $type)) {
+    if (\Drupal::entityManager()->getAccessControlHandler('node')->createAccess($type)) {
       $nodes = TRUE;
       break;
     }
   }
 
-  if (user_access('administer nodes') || $nodes) {
+  if (\Drupal::currentUser()->hasPermission('administer nodes') || $nodes) {
     $form['comment_notify_settings']['node_notify'] = array(
       '#type' => 'checkbox',
       '#title' => t('Receive content follow-up notification e-mails'),
-      '#default_value' => isset($node_notify) ? $node_notify : comment_notify_variable_registry_get('node_notify_default_mailalert'),
+      '#default_value' => isset($node_notify) ? $node_notify : \Drupal::config('comment_notify.settings')->get('enable_default.entity_author'),
       '#description' => t('Check this box to receive an e-mail notification for follow-ups on your content. You can not disable notifications for individual threads.')
     );
   }
@@ -352,28 +247,40 @@ function comment_notify_form_alter(&$form, &$form_state, $form_id) {
   $form['comment_notify_settings']['comment_notify'] = array(
     '#type' => 'select',
     '#title' => t('Receive comment follow-up notification e-mails'),
-    '#default_value' => isset($comment_notify) ? array($comment_notify) : array(comment_notify_variable_registry_get('default_registered_mailalert')),
+    '#default_value' => isset($comment_notify) ? array($comment_notify) : array(\Drupal::config('comment_notify.settings')->get('enable_default.watcher')),
     '#options' => $available_options,
     '#description' => t("Check this box to receive e-mail notification for follow-up comments to comments you posted. You can later disable this on a post-by-post basis... so if you leave this to YES, you can still disable follow-up notifications for comments you don't want follow-up mails anymore - i.e. for very popular posts.")
   );
+
+  // Make sure the notify pseudofields are included when the entity is built.
+  $form['#entity_builders'][] = '_comment_notify_form_build_user_entity';
+
   return $form;
-  // Construct the user form
 }
 
-function comment_notify_user_update(&$edit, $account, $category) {
-  if ($category != 'account') {
-    return;
-  }
-  if (isset($edit['node_notify']) && isset($edit['comment_notify'])) {
+/**
+ * Entity builder for the comment form.
+ */
+function _comment_notify_form_build_user_entity($entity_type_id, EntityInterface $entity, array &$form, FormStateInterface $form_state) {
+  $entity->comment_notify_settings->node_notify = $form_state->getValue('node_notify');
+  $entity->comment_notify_settings->comment_notify = $form_state->getValue('comment_notify');
+}
+
+/**
+ * Implements hook_ENTITY_TYPE_update() for user.
+ */
+function comment_notify_user_update(UserInterface $account) {
+  if ($settings = $account->comment_notify_settings) {
     module_load_include('inc', 'comment_notify', 'comment_notify');
 
-    // Save the values of node_notify_mailalert and comment_notify_mailalert
-    // to {comment_notify_user_settings}.
-    comment_notify_set_user_notification_setting($account->uid, $edit['node_notify'], $edit['comment_notify']);
+    if ($account->isAnonymous()) {
+      return;
+    }
+
+    // Save the comment_notify_settings values to
+    // {comment_notify_user_settings}.
+    comment_notify_set_user_notification_setting($account->id(), $settings->node_notify, $settings->comment_notify);
   }
-  // Unset them from $user so they don't also get saved into {users}.data.
-  unset($edit['node_notify']);
-  unset($edit['comment_notify']);
 
 }
 
@@ -382,10 +289,8 @@ function comment_notify_user_load($users) {
 
   // @todo: Why would we want to load this on every user load?
   foreach ($users as &$user) {
-    $user->comment_notify_settings = comment_notify_get_user_notification_setting($user->uid);
+    $user->comment_notify_settings = comment_notify_get_user_notification_setting($user->id()) ?: comment_notify_get_default_notification_setting();
   }
-
-  return;
 }
 
 function comment_notify_user_cancel($edit, $account, $method) {
@@ -399,9 +304,9 @@ function comment_notify_user_cancel($edit, $account, $method) {
 function comment_notify_comment_load($comments) {
   // Load some comment_notify specific information into the comment object.
   $query = db_select('comment_notify', 'cn');
-  $query->join('comment', 'c', 'c.cid = cn.cid');
-  $query->leftJoin('users', 'u', 'c.uid = u.uid');
-  $query->condition('c.cid', array_keys($comments));
+  $query->join('comment_field_data', 'c', 'c.cid = cn.cid');
+  $query->leftJoin('users_field_data', 'u', 'c.uid = u.uid');
+  $query->condition('c.cid', array_keys($comments), 'IN');
   $query->fields('cn', array('cid', 'notify', 'notify_hash', 'notified'));
   $query->addField('c', 'mail', 'cmail');
   $query->addField('u', 'init', 'uinit');
@@ -422,20 +327,15 @@ function comment_notify_comment_load($comments) {
 /**
  * Private function to send the notifications.
  *
- * @param $comment
- *   The comment array as found in hook_comment $op = publish.
+ * @param \Drupal\comment\CommentInterface $comment
+ *   The comment entity.
  */
-function _comment_notify_mailalert($comment) {
+function _comment_notify_mailalert(CommentInterface $comment) {
   module_load_include('inc', 'comment_notify', 'comment_notify');
 
-  $comment = (object) $comment;
-  global $language;
-  global $base_url;
-  global $user;
-  $initial_language = $language;
-
-  $nid = $comment->nid;
-  $cid = $comment->cid;
+  $config = \Drupal::config('comment_notify.settings');
+  $user = \Drupal::currentUser();
+  $nid = $comment->getCommentedEntityId();
 
   // Check to see if a notification has already been sent for this
   // comment so that edits to a comment don't trigger an additional
@@ -444,45 +344,55 @@ function _comment_notify_mailalert($comment) {
     return;
   }
 
-  $node = node_load($nid);
+  /** @var \Drupal\node\NodeInterface $node */
+  $node = \Drupal::entityManager()->getStorage('node')->load($nid);
 
   // No mails if this is not an enabled content type.
-  $enabled_types = variable_get('comment_notify_node_types', array($node->type => TRUE));
-  if (empty($enabled_types[$node->type])) {
+  $enabled_types = $config->get('node_types') ?: [$node->getEntityTypeId()];
+  if (!in_array($node->bundle(), $enabled_types)) {
     return;
   }
 
-  if (empty($comment->mail)) {
-    $comment_account = user_load_by_name($comment->name);
-    $comment_mail = isset($comment_account->mail) ? $comment_account->mail : '';
+  if (empty($comment->getAuthorEmail())) {
+    /** @var \Drupal\user\UserInterface $comment_account */
+    $comment_account = user_load_by_name($comment->getAuthorName());
+    $comment_mail = $comment_account->getEmail() ?: '';
   }
   else {
-    $comment_mail = $comment->mail;
+    $comment_mail = $comment->getAuthorEmail();
   }
   $sent_to = array();
 
   // Send to a subscribed author if they are not the current commenter.
-  $author = user_load($node->uid);
+  $author = $node->getOwner();
 
   // Do they explicitly want this? Or is it default to send to users?
   // Is the comment author not the node author? Do they have access? Do they have an email (e.g. anonymous)?
-  if (((!empty($author->comment_notify_settings->node_notify) && $author->comment_notify_settings->node_notify == 1) || (comment_notify_variable_registry_get('node_notify_default_mailalert') == 1 && !isset($author->comment_notify_settings->node_notify))) && $user->uid != $author->uid && node_access('view', $node, $author) && !empty($author->mail)) {
+  if (
+    (
+      (!empty($author->comment_notify_settings->node_notify) && $author->comment_notify_settings->node_notify == 1)
+      || ($config->get('enable_default.entity_author') == 1 && !isset($author->comment_notify_settings->node_notify))
+    )
+    && $user->id() != $author->id()
+    && $node->access('view', $author)
+    && !empty($author->getEmail())
+  ) {
     // Get the author's language.
-    $language = user_preferred_language($author);
+    $language = $author->getPreferredLangcode();
     $raw_values = array(
-      'subject' => comment_notify_variable_registry_get('author_subject'),
-      'body'  => comment_notify_variable_registry_get('node_notify_default_mailtext'), //JS @todo:change this.
+      'subject' => $config->get('mail_templates.entity_author.subject'),
+      'body'  => $config->get('mail_templates.entity_author.body'),
     );
     foreach ($raw_values as $k => $v) {
-      $message[$k] = token_replace(t($v), array('comment' => $comment), array('sanitize' => FALSE));
+      $message[$k] = \Drupal::token()->replace(t($v), array('comment' => $comment), array('sanitize' => FALSE));
     }
 
-    drupal_mail('comment_notify', 'comment_notify_mail', $author->mail, $language, $message);
-    $sent_to[] = strtolower($author->mail);
+    \Drupal::service('plugin.manager.mail')->mail('comment_notify', 'comment_notify_mail', $author->getEmail(), $language, $message);
+    $sent_to[] = strtolower($author->getEmail());
   }
 
   // For "reply to my comments" notifications, figure out what thread this is.
-  $thread = isset($comment->thread) ? $comment->thread : '';
+  $thread = $comment->getThread() ?: '';
 
   // Get the list of commenters to notify.
   $watchers = comment_notify_get_watchers($nid);
@@ -490,57 +400,46 @@ function _comment_notify_mailalert($comment) {
   foreach ($watchers as $alert) {
     // If the user is not anonymous, always load the current e-mail address
     // from his or her user account instead of trusting $comment->mail.
-    $recipient_user = !empty($alert->uid) ? user_load($alert->uid) : drupal_anonymous_user();
-    $mail = !empty($recipient_user->mail) ? $recipient_user->mail : $alert->cmail;
+    $recipient_user = $alert->getOwner();
+    $mail = !empty($recipient_user->getEmail()) ? $recipient_user->getEmail() : $alert->getAuthorEmail();
 
-    $relevant_thread = drupal_substr($thread, 0, drupal_strlen($alert->thread) -1);
-    if ($alert->notify == COMMENT_NOTIFY_COMMENT && strcmp($relevant_thread . '/', $alert->thread) != 0) {
+    $relevant_thread = Unicode::substr($thread, 0, Unicode::strlen($alert->getThread()) -1);
+    if ($alert->notify == COMMENT_NOTIFY_COMMENT && strcmp($relevant_thread . '/', $alert->getThread()) != 0) {
       continue;
     }
 
-    if ($mail != $comment_mail && !in_array(strtolower($mail), $sent_to) && ($alert->uid != $comment->uid || $alert->uid == 0)) {
+    if ($mail != $comment_mail && !in_array(strtolower($mail), $sent_to) && ($alert->getOwnerId() != $comment->getOwnerId() || $alert->getOwnerId() == 0)) {
 
       $message = array();
-      $language = !empty($alert->uid) ? user_preferred_language($recipient_user) : language_default();
+      $language = !empty($alert->uid) ? $recipient_user->getPreferredLangcode() : LanguageInterface::LANGCODE_DEFAULT;
 
       // Make sure they have access to this node before showing a bunch of node information.
-      if (!node_access('view', $node, $recipient_user)) {
+      if (!$node->access('view', $recipient_user)) {
         continue;
       }
 
       $raw_values = array(
-        'subject' => comment_notify_variable_registry_get('watcher_subject'),
-        'body'  => comment_notify_variable_registry_get('comment_notify_default_mailtext'), //JS @todo:change this var name.
+        'subject' => $config->get('mail_templates.watcher.subject'),
+        'body'  => $config->get('mail_templates.watcher.body'),
       );
 
       foreach ($raw_values as $k => $v) {
-        $message[$k] = token_replace(t($v), array('comment' => $comment, 'comment-subscribed' => $alert), array('sanitize' => FALSE));
+        $message[$k] = \Drupal::token()->replace(t($v), array('comment' => $comment, 'comment-subscribed' => $alert), array('sanitize' => FALSE));
       }
 
-      drupal_mail('comment_notify', 'comment_notify_mail', $mail, $language, $message);
+      \Drupal::service('plugin.manager.mail')->mail('comment_notify', 'comment_notify_mail', $mail, $language, $message);
       $sent_to[] = strtolower($mail);
 
       // Make the mail link to user's /edit, unless it's an anonymous user.
-      if ($alert->uid != 0) {
-        $user_mail = l($mail, 'user/' . $alert->uid . '/edit');
+      if ($alert->getOwnerId() != 0) {
+        $user_mail = $alert->link($mail, 'edit-form');
       }
       else {
-        $user_mail = check_plain($mail);
+        $user_mail = Html::escape($mail);
       }
 
       // Add an entry to the watchdog log.
-      watchdog(
-        'comment_notify',
-        'Notified: @user_mail',
-        array('@user_mail' => $user_mail),
-          WATCHDOG_NOTICE,
-          l(t('source comment'), 'node/' . $nid, array(
-            'fragment' => 'comment-' . $alert->cid,
-          ))
-      );
-
-      // Revert to previous (site default) locale.
-      $language = $initial_language;
+      \Drupal::logger('comment_notify')->notice('Notified: @user_mail', ['@user_mail' => $user_mail, 'link' => $alert->link(t('source comment'))]);
     }
   }
   // Record that a notification was sent for this comment so that
@@ -557,182 +456,37 @@ function comment_notify_mail($key, &$message, $params) {
 }
 
 /**
- * Callback for an administrative form to unsubscribe users by e-mail address.
- */
-function comment_notify_unsubscribe($form, &$form_state) {
-  $form['comment_notify_unsubscribe'] = array();
-  $form['comment_notify_unsubscribe']['email_to_unsubscribe'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Email to unsubscribe'),
-  );
-  $form['comment_notify_unsubscribe']['submit'] = array(
-    '#type' => 'submit',
-    '#value' => t('Unsubscribe this e-mail'),
-  );
-  return $form;
-}
-
-/**
- * Based on admin submit, do the actual unsubscribe from notifications.
- */
-function comment_notify_unsubscribe_submit($form, &$form_state) {
-  module_load_include('inc', 'comment_notify', 'comment_notify');
-  $email = trim($form_state['values']['email_to_unsubscribe']);
-  $comments = comment_notify_unsubscribe_by_email($email);
-  // Update the admin about the state of this comment notification subscription.
-  if ($comments == 0) {
-    drupal_set_message(t("There were no active comment notifications for that email."));
-  }
-  else {
-    drupal_set_message(format_plural($comments, "Email unsubscribed from 1 comment notification.",
-      "Email unsubscribed from @count comment notifications."));
-  }
-}
-
-/*
- * Page callback for administrative settings form.
- */
-function comment_notify_settings() {
-  module_load_include('inc', 'comment_notify', 'comment_notify');
-
-  $form['comment_notify_settings'] = array();
-
-  // Only perform comment_notify for certain node types.
-  $enabled_types = comment_notify_variable_registry_get('node_types');
-  $anonymous_problems = '';
-  foreach (node_type_get_names() as $type => $name) {
-    $checkboxes[$type] = check_plain($name);
-    $default[] = $type;
-
-    // If they don't have the ability to leave contact info, then we make a report
-    if (isset($enabled_types[$type]) && $enabled_types[$type] && variable_get('comment_anonymous_' . $type, COMMENT_ANONYMOUS_MAYNOT_CONTACT) == COMMENT_ANONYMOUS_MAYNOT_CONTACT) {
-      $account = drupal_anonymous_user();
-      if (user_access('subscribe to comments', $account)) {
-        $anonymous_problems[] = l(t('@content-type', array('@content-type' => $name)), 'admin/structure/types/manage/' . $type);
-      }
-    }
-  }
-
-  if (!empty($anonymous_problems)) {
-    drupal_set_message(t('Anonymous commenters have the permission to subscribe to comments but cannot leave their contact information on the following content types: !types.  You should either disable subscriptions on those types here, revoke the permission for anonymous users, or enable anonymous users to leave their contact information in the comment settings.', array('!types' => implode(', ', $anonymous_problems))), 'status', FALSE);
-  }
-
-  $form['comment_notify_settings']['comment_notify_node_types'] = array(
-    '#type' => 'checkboxes',
-    '#title' => t('Content types to enable for comment notification'),
-    '#default_value' => $enabled_types,
-    '#options' => $checkboxes,
-    '#description' => t('Comments on content types enabled here will have the option of comment notification.'),
-  );
-
-  $form['comment_notify_settings']['comment_notify_available_alerts'] = array(
-    '#type' => 'checkboxes',
-    '#title' => t('Available subscription modes'),
-    '#return_value' => 1,
-    '#default_value' => comment_notify_variable_registry_get('available_alerts'),
-    '#description' => t('Choose which notification subscription styles are available for users'),
-    '#options' => array(
-  COMMENT_NOTIFY_NODE     => t('All comments'),
-  COMMENT_NOTIFY_COMMENT  => t('Replies to my comment')
-  )
-  );
-
-  $available_options[COMMENT_NOTIFY_DISABLED] = t('No notifications');
-  $available_options += _comment_notify_options();
-  $form['comment_notify_settings']['comment_notify_default_anon_mailalert'] = array(
-    '#type' => 'select',
-    '#title' => t('Default state for the notification selection box for anonymous users'),
-    '#return_value' => 1,
-    '#default_value' => comment_notify_variable_registry_get('default_anon_mailalert'),
-    '#options' => $available_options,
-  );
-
-  $form['comment_notify_settings']['comment_notify_default_registered_mailalert'] = array(
-    '#type' => 'select',
-    '#title' => t('Default state for the notification selection box for registered users'),
-    '#return_value' => 1,
-    '#default_value' => comment_notify_variable_registry_get('default_registered_mailalert'),
-    '#description' => t('This flag presets the flag for the follow-up notification on the form that anon users will see when posting a comment'),
-    '#options' => $available_options,
-  );
-
-  $form['comment_notify_settings']['comment_notify_node_notify_default_mailalert'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Subscribe users to their node follow-up notification emails by default'),
-    '#default_value' => comment_notify_variable_registry_get('node_notify_default_mailalert'),
-    '#description' => t('If this is checked, new users will receive e-mail notifications for follow-ups on their nodes by default until they individually disable the feature.'),
-  );
-
-  $form['comment_notify_settings']['comment_notify_comment_notify_default_mailtext'] = array(
-    '#type' => 'textarea',
-    '#title' => t('Default mail text for sending out notifications to commenters'),
-    '#default_value' => comment_notify_variable_registry_get('comment_notify_default_mailtext'),
-    '#return_value' => 1,
-    '#cols' => 80,
-    '#rows' => 15,
-    '#token_types' => array('comment'),
-    '#element_validate' => array('token_element_validate'),
-  );
-
-  $form['comment_notify_settings']['comment_notify_node_notify_default_mailtext'] = array(
-    '#type' => 'textarea',
-    '#title' => t('Default mail text for sending out the notifications to node authors'),
-    '#default_value' => comment_notify_variable_registry_get('node_notify_default_mailtext'),
-     '#return_value' => 1,
-     '#cols' => 80,
-     '#rows' => 15,
-     '#token_types' => array('comment'),
-     '#element_validate' => array('token_element_validate'),
-  );
-
-  $form['comment_notify_settings']['token_help'] = array(
-    '#theme' => 'token_tree',
-    '#token_types' => array('comment'),
-  );
-
-  $form['#validate'] = array('comment_notify_settings_validate');
-
-  return system_settings_form($form);
-}
-
-function comment_notify_settings_validate($form, &$form_state) {
-  $sum_enabled = 0;
-  foreach ($form_state['values']['comment_notify_available_alerts'] as $enabled) {
-    $sum_enabled += $enabled;
-  }
-  if (!$sum_enabled) {
-    form_set_error('comment_notify_available_alerts', 'You must enable at least one subscription mode.');
-  }
-}
-
-/**
  * Get the unsubscribe link for a comment subscriber.
  *
- * @param $comment
+ * @param \Drupal\comment\CommentInterface $comment
  *   The subscribed comment object.
  *
- * @return
- *   A string with the internal path to the unsubscribe link, ready to be
- *   passed to the url() function.
+ * @return \Drupal\Core\Url|null
+ *   A Url object for the unsubscribe page, or NULL if the comment is missing a
+ *   notification hash.
+ *
+ * @todo In what case would a comment be missing its notification hash?
  */
-function comment_notify_get_unsubscribe_url($comment) {
-  module_load_include('inc', 'comment_notify', 'comment_notify');
+function comment_notify_get_unsubscribe_url(CommentInterface $comment) {
   if (!empty($comment->notify_hash)) {
-    return 'comment_notify/disable/' . $comment->notify_hash;
+    return \Drupal::url('comment_notify.disable_page', ['hash' => $comment->notify_hash]);
   }
+  return NULL;
 }
 /**
  * Implements hook_field_extra_fields().
  */
-function comment_notify_field_extra_fields() {
+function comment_notify_entity_extra_field_info() {
   module_load_include('inc', 'comment_notify', 'comment_notify');
   $extras = array();
 
-  foreach (comment_notify_variable_registry_get('node_types') as $node_type) {
-    if (isset($node_type)) {
-      $extras['comment']['comment_node_' . $node_type]['form']['comment_notify_settings'] = array(
+  foreach (\Drupal::config('comment_notify.settings')->get('node_types') as $node_type) {
+    $comment_field = FieldConfig::loadByName('node', $node_type, 'comment');
+    if ($comment_field) {
+      $comment_type = $comment_field->getSetting('comment_type');
+      $extras['comment'][$comment_type]['form']['comment_notify_settings'] = array(
         'label' => t('Comment Notify settings'),
-        'description' => t('@node_type settings for Comment Notify', array('@node_type' => ucwords($node_type))),
+        'description' => t('@node_type settings for Comment Notify', array('@node_type' => NodeType::load($node_type)->label())),
         'weight' => 1,
       );
     }
diff --git a/comment_notify.permissions.yml b/comment_notify.permissions.yml
new file mode 100644
index 0000000..2f5fdf1
--- /dev/null
+++ b/comment_notify.permissions.yml
@@ -0,0 +1,6 @@
+'administer comment notify':
+  title: 'Administer Comment Notify'
+  description: 'Change global comment notification settings.'
+'subscribe to comments':
+  title: 'Subscribe to comment notifications'
+  description: 'Subscribe to recieve notifications when new comments are posted.'
diff --git a/comment_notify.routing.yml b/comment_notify.routing.yml
new file mode 100644
index 0000000..80e4068
--- /dev/null
+++ b/comment_notify.routing.yml
@@ -0,0 +1,23 @@
+comment_notify.settings:
+  path: /admin/config/people/comment_notify
+  defaults:
+    _title: Comment notification
+    _form: \Drupal\comment_notify\Form\CommentNotifySettings
+  requirements:
+    _permission: 'administer comment notify'
+
+comment_notify.unsubscribe:
+  path: /admin/config/people/comment_notify/unsubscribe
+  defaults:
+    _title: Unsubscribe from comment notifications
+    _form: \Drupal\comment_notify\Form\CommentNotifyUnsubscribe
+  requirements:
+    _permission: 'administer comment notify'
+
+comment_notify.disable_page:
+  path: '/comment_notify/disable/{hash}'
+  defaults:
+    _title: 'Disable comment notification'
+    _controller: '\Drupal\comment_notify\Controller\DefaultController::comment_notify_disable_page'
+  requirements:
+    _permission: 'access content'
diff --git a/comment_notify.tokens.inc b/comment_notify.tokens.inc
index 7c89702..fcb66a6 100644
--- a/comment_notify.tokens.inc
+++ b/comment_notify.tokens.inc
@@ -4,6 +4,7 @@
  * @file
  * Builds placeholder replacement tokens for comment_notify.module.
  */
+use Drupal\Core\Render\BubbleableMetadata;
 
 /**
  * Implements hook_token_info().
@@ -29,7 +30,7 @@ function comment_notify_token_info() {
 /**
  * Implements hook_tokens().
  */
-function comment_notify_tokens($type, $tokens, array $data = array(), array $options = array()) {
+function comment_notify_tokens($type, $tokens, array $data = array(), array $options = array(), BubbleableMetadata $bubbleable_metadata) {
   $url_options = array('absolute' => TRUE);
   if (isset($options['language'])) {
     $url_options['language'] = $options['language'];
@@ -49,21 +50,21 @@ function comment_notify_tokens($type, $tokens, array $data = array(), array $opt
       switch ($name) {
         case 'unsubscribe-url':
           if ($unsubscribe_url = comment_notify_get_unsubscribe_url($comment)) {
-            $replacements[$original] = url($unsubscribe_url, $url_options);
+            $replacements[$original] = $unsubscribe_url;
           }
           break;
       }
     }
 
     // [comment:unsubscribe-url:*] chained token replacements.
-    if (($unsubscribe_url_tokens = token_find_with_prefix($tokens, 'unsubscribe-url')) && $unsubscribe_url = comment_notify_get_unsubscribe_url($comment)) {
-      $replacements += token_generate('url', $unsubscribe_url_tokens, array('path' => $unsubscribe_url), $options);
+    if (($unsubscribe_url_tokens = \Drupal::token()->findWithPrefix($tokens, 'unsubscribe-url')) && $unsubscribe_url = comment_notify_get_unsubscribe_url($comment)) {
+      $replacements += \Drupal::token()->generate('url', $unsubscribe_url_tokens, array('path' => $unsubscribe_url), $options, $bubbleable_metadata);
     }
   }
 
   // Comment subscriber tokens (pass through to comment token replacement).
   if ($type == 'comment-subscribed' && !empty($data['comment-subscribed'])) {
-    $replacements += token_generate('comment', $tokens, array('comment' => $data['comment-subscribed']), $options);
+    $replacements += \Drupal::token()->generate('comment', $tokens, array('comment' => $data['comment-subscribed']), $options, $bubbleable_metadata);
   }
 
   return $replacements;
diff --git a/config/install/comment_notify.settings.yml b/config/install/comment_notify.settings.yml
new file mode 100644
index 0000000..a04654b
--- /dev/null
+++ b/config/install/comment_notify.settings.yml
@@ -0,0 +1,53 @@
+node_types:
+  - article
+available_alerts:
+  1: true
+  2: true
+enable_default:
+  watcher: none
+  entity_author: false
+mail_templates:
+  watcher:
+    subject: '[site:name] :: new comment on [comment:node:title]'
+    body: |
+      Hi [comment-subscribed:author],
+
+      [comment:author] has commented on: "[comment:node:title]"
+
+      ----
+      [comment:title]
+      [comment:body]
+      ----
+
+      You can view the comment at the following url
+      [comment:url]
+
+      You can stop receiving emails when someone replies to this post,
+      by going to [comment-subscribed:unsubscribe-url]
+
+      You can set up auto-following feature for all future posts
+      by creating your own user with a few clicks here [site:login-url]
+
+      -- [site:name] team
+      [site:url]
+  entity_author:
+    subject: '[site:name] :: new comment for your post'
+    body: |
+      Hi [comment:node:author],
+
+      You have received a comment on: "[comment:node:title]"
+
+      ----
+      [comment:title]
+      [comment:body]
+      ----
+
+      You can view the comment at the following url
+      [comment:url]
+
+      You will receive emails like this for all replies to your posts. You can
+      disable this by logging in and changing the settings on your user account at
+      [comment:node:author:edit-url].
+
+      -- [site:name] team
+      [site:url]
diff --git a/config/schema/comment_notify.schema.yml b/config/schema/comment_notify.schema.yml
new file mode 100644
index 0000000..4105cfd
--- /dev/null
+++ b/config/schema/comment_notify.schema.yml
@@ -0,0 +1,51 @@
+comment_notify.settings:
+  type: config_object
+  mapping:
+    node_types:
+      type: sequence
+      label: Content types to enable for comment notification
+      sequence:
+        type: string
+    available_alerts:
+      type: mapping
+      label: Available subscription modes
+      mapping:
+        # COMMENT_NOTIFY_NODE
+        1:
+          type: boolean
+        # COMMENT_NOTIFY_COMMENT
+        2:
+          type: boolean
+    enable_default:
+      type: mapping
+      mapping:
+        watcher:
+          type: string
+          label: Default state for the notification selection box
+        entity_author:
+          type: boolean
+          label: Subscribe users to their node follow-up notification emails by default
+    mail_templates:
+      type: mapping
+      label: Default mail text for sending out notifications
+      mapping:
+        watcher:
+          type: mapping
+          label: Notifications to commenters
+          mapping:
+            subject:
+              type: label
+              label: Subject
+            body:
+              type: text
+              label: Body
+        entity_author:
+          type: mapping
+          label: Notifications to owner of commented entity
+          mapping:
+            subject:
+              type: label
+              label: Subject
+            body:
+              type: text
+              label: Body
diff --git a/src/Controller/DefaultController.php b/src/Controller/DefaultController.php
new file mode 100644
index 0000000..01cd3f4
--- /dev/null
+++ b/src/Controller/DefaultController.php
@@ -0,0 +1,25 @@
+<?php /**
+ * @file
+ * Contains \Drupal\comment_notify\Controller\DefaultController.
+ */
+
+namespace Drupal\comment_notify\Controller;
+
+use Drupal\Core\Controller\ControllerBase;
+
+/**
+ * Default controller for the comment_notify module.
+ */
+class DefaultController extends ControllerBase {
+
+  public function comment_notify_disable_page($hash) {
+    module_load_include('inc', 'comment_notify', 'comment_notify');
+    if (comment_notify_unsubscribe_by_hash($hash)) {
+      return(t('Your comment follow-up notification for this post was disabled. Thanks.'));
+    }
+    else {
+      return(t('Sorry, there was a problem unsubscribing from notifications.'));
+    }
+  }
+
+}
diff --git a/src/Form/CommentNotifySettings.php b/src/Form/CommentNotifySettings.php
new file mode 100644
index 0000000..e4f174e
--- /dev/null
+++ b/src/Form/CommentNotifySettings.php
@@ -0,0 +1,172 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\comment_notify\Form\CommentNotifySettings.
+ */
+
+namespace Drupal\comment_notify\Form;
+
+use Drupal\Component\Utility\Html;
+use Drupal\Core\Form\ConfigFormBase;
+use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\Render\Element;
+use Drupal\field\Entity\FieldConfig;
+use Drupal\node\Entity\NodeType;
+use Drupal\user\Entity\User;
+
+/**
+ * Settings form for the Comment Notify module.
+ */
+class CommentNotifySettings extends ConfigFormBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getFormId() {
+    return 'comment_notify_settings';
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function getEditableConfigNames() {
+    return ['comment_notify.settings'];
+  }
+
+  public function buildForm(array $form, FormStateInterface $form_state) {
+    $config = $this->config('comment_notify.settings');
+
+    // Only perform comment_notify for certain node types.
+    $enabled_types = $config->get('node_types');
+    $anonymous_problems = '';
+    $checkboxes = [];
+    foreach (NodeType::loadMultiple() as $type_id => $type) {
+      $checkboxes[$type_id] = Html::escape($type->label());
+      $default[] = $type_id;
+
+      // If they don't have the ability to leave contact info, then we make a report
+      $comment_field = FieldConfig::loadByName('node', $type_id, 'comment');
+      if (in_array($type_id, $enabled_types) && $comment_field && $comment_field->getSetting('anonymous') == COMMENT_ANONYMOUS_MAYNOT_CONTACT) {
+        if (User::getAnonymousUser()->hasPermission('subscribe to comments')) {
+          $anonymous_problems[] = $type->link($type->label());
+        }
+      }
+    }
+
+    if (!empty($anonymous_problems)) {
+      drupal_set_message($this->t('Anonymous commenters have the permission to subscribe to comments but cannot leave their contact information on the following content types: !types.  You should either disable subscriptions on those types here, revoke the permission for anonymous users, or enable anonymous users to leave their contact information in the comment settings.', [
+        '!types' => implode(', ', $anonymous_problems),
+      ]), 'status', FALSE);
+    }
+
+    $form['node_types'] = [
+      '#type' => 'checkboxes',
+      '#title' => $this->t('Content types to enable for comment notification'),
+      '#default_value' => $enabled_types,
+      '#options' => $checkboxes,
+      '#description' => $this->t('Comments on content types enabled here will have the option of comment notification.'),
+    ];
+
+    $form['available_alerts'] = [
+      '#type' => 'checkboxes',
+      '#title' => $this->t('Available subscription modes'),
+      '#return_value' => 1,
+      '#default_value' => array_keys(array_filter($config->get('available_alerts'))),
+      '#description' => $this->t('Choose which notification subscription styles are available for users'),
+      '#options' => [
+        COMMENT_NOTIFY_NODE => $this->t('All comments'),
+        COMMENT_NOTIFY_COMMENT => $this->t('Replies to my comment'),
+      ],
+    ];
+
+    $available_options[COMMENT_NOTIFY_DISABLED] = $this->t('No notifications');
+    $available_options += _comment_notify_options();
+
+    $form['enable_default'] = [
+      '#type' => 'container',
+      '#tree' => TRUE,
+    ];
+
+    $form['enable_default']['watcher'] = [
+      '#type' => 'select',
+      '#title' => $this->t('Default state for the notification selection box'),
+      '#return_value' => 1,
+      '#default_value' => $config->get('enable_default.watcher'),
+      '#description' => $this->t('This flag presets the flag for the follow-up notification on the form that users will see when posting a comment'),
+      '#options' => $available_options,
+    ];
+
+    $form['enable_default']['entity_author'] = [
+      '#type' => 'checkbox',
+      '#title' => $this->t('Subscribe users to their node follow-up notification emails by default'),
+      '#default_value' => $config->get('enable_default.entity_author'),
+      '#description' => $this->t('If this is checked, new users will receive e-mail notifications for follow-ups on their nodes by default until they individually disable the feature.'),
+    ];
+
+    $form['mail_templates'] = [
+      '#type' => 'container',
+      '#tree' => TRUE,
+    ];
+
+    $form['mail_templates']['watcher'] = [
+      '#type' => 'container',
+      '#tree' => TRUE,
+    ];
+
+    $form['mail_templates']['watcher']['body'] = [
+      '#type' => 'textarea',
+      '#title' => $this->t('Default mail text for sending out notifications to commenters'),
+      '#default_value' => $config->get('mail_templates.watcher.body'),
+      '#cols' => 80,
+      '#rows' => 15,
+      '#token_types' => [
+        'comment'
+      ],
+      '#element_validate' => ['token_element_validate'],
+    ];
+
+    $form['mail_templates']['entity_author'] = [
+      '#type' => 'container',
+      '#tree' => TRUE,
+    ];
+
+    $form['mail_templates']['entity_author']['body'] = [
+      '#type' => 'textarea',
+      '#title' => $this->t('Default mail text for sending out the notifications to node authors'),
+      '#default_value' => $config->get('mail_templates.entity_author.body'),
+      '#cols' => 80,
+      '#rows' => 15,
+      '#token_types' => [
+        'comment'
+      ],
+      '#element_validate' => ['token_element_validate'],
+    ];
+
+    $form['token_help'] = [
+      '#theme' => 'token_tree',
+      '#token_types' => [
+        'comment'
+      ],
+    ];
+
+    return parent::buildForm($form, $form_state);
+  }
+
+  public function validateForm(array &$form, FormStateInterface $form_state) {
+    if (!array_filter($form_state->getValue('available_alerts'))) {
+      $form_state->setErrorByName('available_alerts', 'You must enable at least one subscription mode.');
+    }
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function submitForm(array &$form, FormStateInterface $form_state) {
+    $this->config('comment_notify.settings')
+      ->setData($form_state->getValues())
+      ->save();
+    parent::submitForm($form, $form_state);
+  }
+
+}
diff --git a/src/Form/CommentNotifyUnsubscribe.php b/src/Form/CommentNotifyUnsubscribe.php
new file mode 100644
index 0000000..b830b3c
--- /dev/null
+++ b/src/Form/CommentNotifyUnsubscribe.php
@@ -0,0 +1,61 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\comment_notify\Form\CommentNotifyUnsubscribe.
+ */
+
+namespace Drupal\comment_notify\Form;
+
+use Drupal\Core\Form\ConfigFormBase;
+use Drupal\Core\Render\Element;
+
+/**
+ * Unsubscribe form for Comment Notify.
+ */
+class CommentNotifyUnsubscribe extends ConfigFormBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function getEditableConfigNames() {
+    return [];
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getFormId() {
+    return 'comment_notify_unsubscribe';
+  }
+
+  public function buildForm(array $form, \Drupal\Core\Form\FormStateInterface $form_state) {
+    $form['comment_notify_unsubscribe'] = [];
+
+    $form['comment_notify_unsubscribe']['email'] = [
+      '#type' => 'textfield',
+      '#title' => t('Email to unsubscribe'),
+      '#description' => $this->t('All comment notification requests associated with this email will be revoked.'),
+      '#required' => TRUE,
+    ];
+    $form['comment_notify_unsubscribe']['submit'] = [
+      '#type' => 'submit',
+      '#value' => t('Unsubscribe this e-mail'),
+    ];
+    return $form;
+  }
+
+  public function submitForm(array &$form, \Drupal\Core\Form\FormStateInterface $form_state) {
+    module_load_include('inc', 'comment_notify', 'comment_notify');
+    $email = trim($form_state->getValue(['email']));
+    $comments = comment_notify_unsubscribe_by_email($email);
+    // Update the admin about the state of this comment notification subscription.
+    if ($comments == 0) {
+      drupal_set_message(t("There were no active comment notifications for that email."));
+    }
+    else {
+      drupal_set_message($this->formatPlural($comments, "Email unsubscribed from 1 comment notification.", "Email unsubscribed from @count comment notifications."));
+    }
+  }
+
+}
diff --git a/comment_notify.test b/src/Tests/CommentNotifyTest.php
similarity index 57%
rename from comment_notify.test
rename to src/Tests/CommentNotifyTest.php
index 56c7a32..de78bad 100644
--- a/comment_notify.test
+++ b/src/Tests/CommentNotifyTest.php
@@ -1,29 +1,38 @@
 <?php
-
 /**
  * @file
- * Creates tests for comment_notify module.
+ * Contains \Drupal\comment_notify\Tests\CommentNotifyTest.
  */
-class CommentNotifyTestCase extends DrupalWebTestCase {
-  /**
-   * Implementation of getInfo().
-   */
-  public static function getInfo() {
-    return array(
-      'name' => t('Comment notify general tests'),
-      'description' => t('Test the various comment notification settings.'),
-      'group' => t('Comment notify'),
-    );
-  }
+namespace Drupal\comment_notify\Tests;
+
+use Drupal\comment\Tests\CommentTestTrait;
+use Drupal\Core\Entity\Entity\EntityViewDisplay;
+use Drupal\Core\Language\Language;
+use Drupal\Core\Session\AccountInterface;
+use Drupal\field\Entity\FieldConfig;
+use Drupal\field\Entity\FieldStorageConfig;
+use Drupal\node\NodeInterface;
+use Drupal\simpletest\WebTestBase;
+
+/**
+ * Comment notify general tests.
+ *
+ * @group comment_notify
+ */
+class CommentNotifyTest extends WebTestBase {
+  use CommentTestTrait;
 
   /**
-   * Implementation of setUp().
+   * Modules to enable.
+   *
+   * @var array
    */
-  function setUp() {
-    parent::setUp('comment_notify');
-    // Create a content type where commenting is enabled.
-    // Allow contact info for anons on that content type, and make preview optional.
-  }
+  protected static $modules = [
+    'comment_notify',
+    'node',
+    'comment',
+    'token',
+  ];
 
   /**
    * Test various behaviors for anonymous users.
@@ -35,37 +44,40 @@ class CommentNotifyTestCase extends DrupalWebTestCase {
     $this->drupalLogin($admin_user);
 
     // Enable comment notify on this node and allow anonymous information in comments.
-    variable_set('comment_notify_node_types', array('article' => 'article', 'page' => 0));
-    variable_set('comment_anonymous_article', '1');
+    $this->drupalCreateContentType([
+      'type' => 'article',
+    ]);
+    $this->addDefaultCommentField('node', 'article');
+    $comment_field = FieldConfig::loadByName('node', 'article', 'comment');
+    $comment_field->setSetting('anonymous', COMMENT_ANONYMOUS_MAY_CONTACT);
+    $comment_field->save();
 
     // Create a node with comments allowed.
-    $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => NODE_PROMOTED, 'comment' => COMMENT_NODE_OPEN));
+    $node = $this->drupalCreateNode(array('type' => 'article', 'promote' => NODE_PROMOTED));
 
     // Allow anonymous users to post comments and get notifications.
-    user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access comments', 'access content', 'post comments', 'skip comment approval', 'subscribe to comments'));
+    user_role_grant_permissions(AccountInterface::ANONYMOUS_ROLE, array('access comments', 'access content', 'post comments', 'skip comment approval', 'subscribe to comments'));
     $this->drupalLogout();
 
     // Notify type 1 - All comments on the node.
     // First confirm that we properly require an e-mail address.
-    $subscribe_1 = array('notify' => TRUE, 'notify_type' => 1);
-    $this->postCommentNotifyComment($this->node, $this->randomName(), $this->randomName(), $subscribe_1);
-
-    // This is still a bad test to test for a static string showing on the page, but at least the definition of the string is centralized.
-    $expected_error = comment_notify_variable_registry_get('error_anonymous_email_missing');
-    $this->assertText(t($expected_error));
+    $subscribe_1 = array('notify' => TRUE, 'notify_type' => COMMENT_NOTIFY_NODE);
+    $this->drupalGet($node->url());
+    $this->postCommentNotifyComment($node, $this->randomMachineName(), $this->randomMachineName(), $subscribe_1);
+    $this->assertText(t('If you want to subscribe to comments you must supply a valid e-mail address.'));
 
     // Try again with an e-mail address.
-    $contact_1 = array('name' => $this->randomName(), 'mail' => $this->getRandomEmailAddress());
-    $anonymous_comment_1 = $this->postCommentNotifyComment($this->node, $this->randomName(), $this->randomName(), $subscribe_1, $contact_1);
+    $contact_1 = array('name' => $this->randomMachineName(), 'mail' => $this->getRandomEmailAddress());
+    $anonymous_comment_1 = $this->postCommentNotifyComment($node, $this->randomMachineName(), $this->randomMachineName(), $subscribe_1, $contact_1);
 
     // Confirm that the notification is saved.
     $result = comment_notify_get_notification_type($anonymous_comment_1['id']);
     $this->assertEqual($result, $subscribe_1['notify_type'], 'Notify selection option 1 is saved properly.');
 
     // Notify type 2 - replies to a comment.
-    $subscribe_2 = array('notify' => TRUE, 'notify_type' => 2);
-    $contact_2 = array('name' => $this->randomName(), 'mail' => $this->getRandomEmailAddress());
-    $anonymous_comment_2 = $this->postCommentNotifyComment($this->node, $this->randomName(), $this->randomName(), $subscribe_2, $contact_2);
+    $subscribe_2 = array('notify' => TRUE, 'notify_type' => COMMENT_NOTIFY_COMMENT);
+    $contact_2 = array('name' => $this->randomMachineName(), 'mail' => $this->getRandomEmailAddress());
+    $anonymous_comment_2 = $this->postCommentNotifyComment($node, $this->randomMachineName(), $this->randomMachineName(), $subscribe_2, $contact_2);
 
     // Confirm that the notification is saved.
     $result = comment_notify_get_notification_type($anonymous_comment_2['id']);
@@ -75,10 +87,10 @@ class CommentNotifyTestCase extends DrupalWebTestCase {
     $this->assertMail('to', $contact_1['mail'], t('Message was sent to the proper anonymous user.'));
 
     // Notify type 0 (i.e. only one mode is enabled).
-    variable_set('comment_notify_available_alerts', array(1 => 0, 2 => 2));
+    \Drupal::configFactory()->getEditable('comment_notify.settings')->set('available_alerts', [1 => FALSE, 2 => TRUE])->save();
     $subscribe_0 = array('notify' => TRUE);
     $contact_0 = array('mail' => $this->getRandomEmailAddress());
-    $anonymous_comment_0 = $this->postCommentNotifyComment($this->node, $this->randomName(), $this->randomName(), $subscribe_0, $contact_0);
+    $anonymous_comment_0 = $this->postCommentNotifyComment($node, $this->randomMachineName(), $this->randomMachineName(), $subscribe_0, $contact_0);
 
     // Confirm that the notification is saved.
     $result = comment_notify_get_notification_type($anonymous_comment_0['id']);
@@ -87,11 +99,6 @@ class CommentNotifyTestCase extends DrupalWebTestCase {
     // TODO yet more tests.
   }
 
-  /////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
-  ////////////////////////// COPIED FROM 7.X COMMENT.TEST \\\\\\\\\\\\\\\\\\\\\
-  //////////////////////////////and tweaked a little\\\\\\\\\\\\\\\\\\\\\\\\\\\
-  /////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
-
   /**
    * Post comment.
    *
@@ -101,11 +108,10 @@ class CommentNotifyTestCase extends DrupalWebTestCase {
    * @param boolean $preview Should preview be required.
    * @param mixed $contact Set to NULL for no contact info, TRUE to ignore success checking, and array of values to set contact info.
    */
-  function postCommentNotifyComment($node, $subject, $comment, $notify, $contact = NULL) {
-    $langcode = LANGUAGE_NONE;
+  protected function postCommentNotifyComment(NodeInterface $node, $subject, $comment, $notify, $contact = NULL) {
     $edit = array();
-    $edit['subject'] = $subject;
-    $edit['comment_body[' . $langcode . '][0][value]'] = $comment;
+    $edit['subject[0][value]'] = $subject;
+    $edit['comment_body[0][value]'] = $comment;
 
     if ($notify !== NULL && is_array($notify)) {
       $edit += $notify;
@@ -115,7 +121,7 @@ class CommentNotifyTestCase extends DrupalWebTestCase {
       $edit += $contact;
     }
 
-    $this->drupalPost('node/' . $node->nid, $edit, t('Save'));
+    $this->drupalPostForm($node->url(), $edit, t('Save'));
 
     $match = array();
     // Get comment ID
@@ -151,7 +157,7 @@ class CommentNotifyTestCase extends DrupalWebTestCase {
       $regex .= $comment->comment . '(.*?)'; // Match comment.
       $regex .= '<\/div>/s'; // Dot matches newlines and ensure that match doesn't bleed outside comment div.
 
-      return (boolean)preg_match($regex, $this->drupalGetContent());
+      return (boolean)preg_match($regex, $this->getRawContent());
     }
     else {
       return FALSE;
@@ -164,6 +170,6 @@ class CommentNotifyTestCase extends DrupalWebTestCase {
    * @return string.
    */
   function getRandomEmailAddress() {
-    return $this->randomName() . '@example.com';
+    return $this->randomMachineName() . '@example.com';
   }
 }
