function StatusMessages::renderMessages
Same name in other branches
- 9 core/lib/Drupal/Core/Render/Element/StatusMessages.php \Drupal\Core\Render\Element\StatusMessages::renderMessages()
- 10 core/lib/Drupal/Core/Render/Element/StatusMessages.php \Drupal\Core\Render\Element\StatusMessages::renderMessages()
- 11.x core/lib/Drupal/Core/Render/Element/StatusMessages.php \Drupal\Core\Render\Element\StatusMessages::renderMessages()
#lazy_builder callback; replaces placeholder with messages.
Parameters
string|null $type: Limit the messages returned by type. Defaults to NULL, meaning all types. Passed on to \Drupal\Core\Messenger\Messenger::deleteByType(). These values are supported:
- NULL
- 'status'
- 'warning'
- 'error'
Return value
array A renderable array containing the messages.
See also
\Drupal\Core\Messenger\Messenger::deleteByType()
1 call to StatusMessages::renderMessages()
- QuickEditImageController::upload in core/
modules/ image/ src/ Controller/ QuickEditImageController.php - Returns JSON representing the new file upload, or validation errors.
File
-
core/
lib/ Drupal/ Core/ Render/ Element/ StatusMessages.php, line 87
Class
- StatusMessages
- Provides a messages element.
Namespace
Drupal\Core\Render\ElementCode
public static function renderMessages($type = NULL) {
$render = [];
if (isset($type)) {
$messages = [
$type => \Drupal::messenger()->deleteByType($type),
];
}
else {
$messages = \Drupal::messenger()->deleteAll();
}
if ($messages) {
// Render the messages.
$render = [
'#theme' => 'status_messages',
'#message_list' => $messages,
'#status_headings' => [
'status' => t('Status message'),
'error' => t('Error message'),
'warning' => t('Warning message'),
],
];
}
return $render;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.