You are here

public static function StatusMessages::renderMessages in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 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_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 68
Contains \Drupal\Core\Render\Element\StatusMessages.

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'),
    ],
  ];
}