function template_preprocess_private_message in Private Message 8
Same name and namespace in other branches
- 8.2 private_message.module \template_preprocess_private_message()
Prepares variables for private_message templates.
Default template: private-message.html.twig.
Parameters
array $variables: An associative array containing:
- elements: An array of elements to display in view mode.
- private_message: The private messsage object.
- view_mode: View mode; e.g., 'full', 'teaser', etc.
File
- ./
private_message.module, line 544 - Contains hooks for the private message module.
Code
function template_preprocess_private_message(array &$variables) {
$variables['view_mode'] = $variables['elements']['#view_mode'];
// Provide a distinct $teaser boolean.
$variables['private_message'] = $variables['elements']['#private_message'];
$private_message = $variables['private_message'];
$variables['url'] = $private_message
->url('canonical', [
'language' => $private_message
->language(),
]);
// Helpful $content variable for templates.
$variables += [
'content' => [],
];
foreach (Element::children($variables['elements']) as $key) {
$variables['content'][$key] = $variables['elements'][$key];
}
}