You are here

protected function MessageDigestTrait::getRenderedMessage in Message Digest 8

Returns the message rendered in the given view mode.

Parameters

\Drupal\message\MessageInterface $message: The message to render.

string $view_mode: The view mode to use.

Return value

string The rendered message.

2 calls to MessageDigestTrait::getRenderedMessage()
MessageDigestSubContext::assertDigestContains in ./message_digest.behat.inc
Checks that the digest for a user contains a certain message.
MessageDigestSubContext::assertDigestNotContains in ./message_digest.behat.inc
Checks that the digest for a user does not contain a certain message.

File

src/Traits/MessageDigestTrait.php, line 69

Class

MessageDigestTrait
Methods useful for testing and integrating the Message Digest module.

Namespace

Drupal\message_digest\Traits

Code

protected function getRenderedMessage(MessageInterface $message, $view_mode) {
  $content = \Drupal::entityTypeManager()
    ->getViewBuilder('message')
    ->view($message, $view_mode);
  return (string) \Drupal::service('renderer')
    ->renderPlain($content);
}