You are here

function comment_notify_get_unsubscribe_url in Comment Notify 8

Same name and namespace in other branches
  1. 7 comment_notify.module \comment_notify_get_unsubscribe_url()

Get the unsubscribe link for a comment subscriber.

@todo In what case would a comment be missing its notification hash?

Parameters

\Drupal\comment\CommentInterface $comment: The subscribed comment object.

Return value

string|null An absolute URL string for the unsubscribe page, or NULL if the comment is missing a notification hash.

2 calls to comment_notify_get_unsubscribe_url()
CommentNotifyTokenReplaceTest::testNodeTokenReplacement in tests/src/Kernel/CommentNotifyTokenReplaceTest.php
Tests the tokens generated by comment notify.
comment_notify_tokens in ./comment_notify.tokens.inc
Implements hook_tokens().

File

./comment_notify.module, line 554
This module provides comment follow-up e-mail notifications.

Code

function comment_notify_get_unsubscribe_url(CommentInterface $comment) {
  if (!empty($comment->notify_hash)) {
    return Url::fromRoute('comment_notify.disable', [
      'hash' => $comment->notify_hash,
    ])
      ->setAbsolute()
      ->toString();
  }
  return NULL;
}