You are here

function update_mail in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/update/update.module \update_mail()

Implements hook_mail().

Constructs the email notification message when the site is out of date.

Parameters

$key: Unique key to indicate what message to build, always 'status_notify'.

$message: Reference to the message array being built.

$params: Array of parameters to indicate what kind of text to include in the message body. This is a keyed array of message type ('core' or 'contrib') as the keys, and the status reason constant (UPDATE_NOT_SECURE, etc) for the values.

See also

\Drupal\Core\Mail\MailManagerInterface::mail()

_update_cron_notify()

_update_message_text()

File

core/modules/update/update.module, line 445
Handles updates of Drupal core and contributed projects.

Code

function update_mail($key, &$message, $params) {
  $langcode = $message['langcode'];
  $language = \Drupal::languageManager()
    ->getLanguage($langcode);
  $message['subject'] .= t('New release(s) available for @site_name', array(
    '@site_name' => \Drupal::config('system.site')
      ->get('name'),
  ), array(
    'langcode' => $langcode,
  ));
  foreach ($params as $msg_type => $msg_reason) {
    $message['body'][] = _update_message_text($msg_type, $msg_reason, $langcode);
  }
  $message['body'][] = t('See the available updates page for more information:', array(), array(
    'langcode' => $langcode,
  )) . "\n" . \Drupal::url('update.status', [], [
    'absolute' => TRUE,
    'language' => $language,
  ]);
  if (_update_manager_access()) {
    $message['body'][] = t('You can automatically install your missing updates using the Update manager:', array(), array(
      'langcode' => $langcode,
    )) . "\n" . \Drupal::url('update.report_update', [], [
      'absolute' => TRUE,
      'language' => $language,
    ]);
  }
  $settings_url = \Drupal::url('update.settings', [], [
    'absolute' => TRUE,
  ]);
  if (\Drupal::config('update.settings')
    ->get('notification.threshold') == 'all') {
    $message['body'][] = t('Your site is currently configured to send these emails when any updates are available. To get notified only for security updates, @url.', array(
      '@url' => $settings_url,
    ));
  }
  else {
    $message['body'][] = t('Your site is currently configured to send these emails only when security updates are available. To get notified for any available updates, @url.', array(
      '@url' => $settings_url,
    ));
  }
}