public function AMPService::devMessage in Accelerated Mobile Pages (AMP) 8.3
Display a development message.
Determines if this is a page where a message should be displayed, then renders the message.
Parameters
mixed $message: Could be a render array or a string.
string $method: The message method to use, defaults to 'addMessage'. Set message to empty or invalid value to just return the message instead of displaying it.
Return value
string Returns the message.
File
- src/
Service/ AMPService.php, line 192
Class
- AMPService
- Class AMPService.
Namespace
Drupal\amp\ServiceCode
public function devMessage($message, $method = 'addMessage') {
$user = \Drupal::currentUser();
if ($this
->isDevPage() && $user
->hasPermission('administer nodes')) {
$rendered_message = \Drupal\Core\Render\Markup::create($message);
$translated_message = new TranslatableMarkup('@message', array(
'@message' => $rendered_message,
));
if (method_exists($this->messenger, $method)) {
$this->messenger
->{$method}($translated_message);
}
return $translated_message;
}
}