You are here

function protected_pages_mail in Protected Pages 8

Same name and namespace in other branches
  1. 7.2 protected_pages.module \protected_pages_mail()
  2. 7 protected_pages.module \protected_pages_mail()

Implements hook_mail().

File

./protected_pages.module, line 20
This module allows you to protect any page of the website by secure password.

Code

function protected_pages_mail($key, &$message, $params) {
  switch ($key) {

    // Send a simple message from the contact form.
    case 'protected_pages_details_mail':
      $tokens = [
        '[protected-page-url]',
        '[site-name]',
      ];
      $replacements = [
        $params['protected_page_url'],
        \Drupal::config('system.site')
          ->get('name'),
      ];
      $body = str_replace($tokens, $replacements, $params['body']);
      $subject = $params['subject'];
      $message['subject'] = Html::escape($subject);
      $message['body'][] = Html::escape($body);
      break;
  }
}