function hook_private_message_view_alter in Private Message 8.2
Alter the private message render array before it is rendered.
Parameters
array $build: The render array representing the private message.
\Drupal\Core\Entity\EntityInterface $privateMessage: The private message entity being rendered.
string $viewMode: The view mode being rendered on the private message.
1 invocation of hook_private_message_view_alter()
- PrivateMessageViewBuilder::view in src/
Entity/ Builder/ PrivateMessageViewBuilder.php - Builds the render array for the provided entity.
File
- ./
private_message.api.php, line 20 - Hook documentation for Private Message module hooks.
Code
function hook_private_message_view_alter(array &$build, EntityInterface $privateMessage, $viewMode) {
// Create a new class specific to the author of the message.
$class = 'private-message-author-' . $privateMessage
->getOwnerId();
// Add the class to the wrapper.
$build['wrapper']['#attributes']['class'][] = $class;
}