You are here

function template_preprocess_private_message_notification_block in Private Message 8

Same name and namespace in other branches
  1. 8.2 private_message.theme.inc \template_preprocess_private_message_notification_block()

Implements hook_preprocess_private_message_notification_block().

File

./private_message.theme.inc, line 14
Contains preprocess functions for the private message module.

Code

function template_preprocess_private_message_notification_block(&$vars) {
  $vars['notification_image_path'] = base_path() . drupal_get_path('module', 'private_message') . '/images/private-message-notification-icon.png';
  $link_title = $vars['new_message_count'] ? \Drupal::service('string_translation')
    ->formatPlural($vars['new_message_count'], 'You have 1 unread private message', 'You have @count unread private messages') : t('You have no unread private messages');
  $url = Url::fromRoute('private_message.private_message_page', [], [
    'attributes' => [
      'title' => $link_title,
      'class' => [
        'private-message-page-link',
      ],
    ],
  ]);
  $count = $vars['new_message_count'] > 99 ? '99+' : $vars['new_message_count'];
  $vars['private_message_page_link'] = Link::fromTextAndUrl($count, $url)
    ->toString();
  $vars['unread_notification_class'] = $vars['new_message_count'] ? 'unread-threads' : '';
}