You are here

public function CasHelper::getMessage in CAS 8

Same name and namespace in other branches
  1. 2.x src/Service/CasHelper.php \Drupal\cas\Service\CasHelper::getMessage()

Returns a translated configurable message given the message config key.

Parameters

string $key: The message config key.

Return value

\Drupal\Component\Render\MarkupInterface|string The customized message or an empty string.

Throws

\InvalidArgumentException If the passed key don't match a config entry.

File

src/Service/CasHelper.php, line 220

Class

CasHelper
Class CasHelper.

Namespace

Drupal\cas\Service

Code

public function getMessage($key) {
  assert($key && is_string($key));
  $message = $this->settings
    ->get($key);
  if ($message === NULL || !is_string($message)) {
    throw new \InvalidArgumentException("Invalid key '{$key}'");
  }

  // Empty string.
  if (!$message) {
    return '';
  }
  return new FormattableMarkup(Xss::filter($this->token
    ->replace($message)), []);
}