You are here

public function Message::getText in Message 8

Replace arguments with their placeholders.

Parameters

string $langcode: The language code.

null|int $delta: The delta of the message to return. If NULL all the message text will be returned.

Return value

array The message text.

Overrides MessageInterface::getText

1 call to Message::getText()
Message::__toString in src/Entity/Message.php
Convert message contents to a string.

File

src/Entity/Message.php, line 206

Class

Message
Defines the Message entity class.

Namespace

Drupal\message\Entity

Code

public function getText($langcode = NULL, $delta = NULL) {
  if (!($message_template = $this
    ->getTemplate())) {

    // Message template does not exist any more.
    // We don't throw an exception, to make sure we don't break sites that
    // removed the message template, so we silently ignore.
    return [];
  }
  if (!$langcode) {
    $langcode = $this->language;
  }
  $message_arguments = $this
    ->getArguments();
  $message_template_text = $message_template
    ->getText($langcode, $delta);
  $output = $this
    ->processArguments($message_arguments, $message_template_text);
  $token_options = $message_template
    ->getSetting('token options', []);
  if (!empty($token_options['token replace'])) {

    // Token should be processed.
    $output = $this
      ->processTokens($output, !empty($token_options['clear']));
  }
  return $output;
}