StatusMessages::renderMessages

public static StatusMessages::renderMessages($type)

#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_get_messages(). These values are supported:

  • NULL
  • 'status'
  • 'warning'
  • 'error'

Return value

array A renderable array containing the messages.

See also

drupal_get_messages()

File

core/lib/Drupal/Core/Render/Element/StatusMessages.php, line 75

Class

StatusMessages
Provides a messages element.

Namespace

Drupal\Core\Render\Element

Code

public static function renderMessages($type) {
  // Render the messages.
  return [
    '#theme' => 'status_messages',
    // @todo Improve when https://www.drupal.org/node/2278383 lands.
    '#message_list' => drupal_get_messages($type),
    '#status_headings' => [
      'status' => t('Status message'),
      'error' => t('Error message'),
      'warning' => t('Warning message'),
    ],
  ];
}
doc_Drupal
2016-10-29 09:44:30
Comments
Leave a Comment

Please login to continue.