You are here

function template_preprocess_private_message_thread in Private Message 8.2

Same name and namespace in other branches
  1. 8 private_message.module \template_preprocess_private_message_thread()

Prepares variables for private_message_thread templates.

Default template: private-message-thread.html.twig.

Parameters

array $variables: An associative array containing:

  • elements: An array of elements to display in view mode.
  • private_message_thread: The private message thread object.
  • view_mode: View mode; e.g., 'full', 'teaser', etc.

File

./private_message.module, line 404
Contains hooks for the private message module.

Code

function template_preprocess_private_message_thread(array &$variables) {
  $variables['view_mode'] = $variables['elements']['#view_mode'];

  // Provide a distinct $teaser boolean.
  $variables['private_message_thread'] = $variables['elements']['#private_message_thread'];

  /** @var \Drupal\private_message\Entity\PrivateMessageThreadInterface $private_message_thread */
  $private_message_thread = $variables['private_message_thread'];
  $variables['last_update'] = \Drupal::service('renderer')
    ->render($variables['elements']['updated']);
  $variables['url'] = $private_message_thread
    ->toUrl('canonical', [
    'language' => $private_message_thread
      ->language(),
  ]);

  // Helpful $content variable for templates.
  $variables += [
    'content' => [],
  ];
  foreach (Element::children($variables['elements']) as $key) {
    $variables['content'][$key] = $variables['elements'][$key];
  }
}