You are here

function better_messages_status_messages_pre_render in Better Messages 8

Pre render callback for 'status_messages' render element.

1 string reference to 'better_messages_status_messages_pre_render'
better_messages_element_info_alter in ./better_messages.module
Implements hook_element_info_alter().

File

./better_messages.module, line 40
Better messages module file.

Code

function better_messages_status_messages_pre_render(array $element) {

  // The code below is heavily copied from StatusMessages::renderMessages().
  $element = [
    '#lazy_builder' => [
      'better_messages_status_messages_lazy_builder',
      [
        $element['#display'],
      ],
    ],
    '#create_placeholder' => TRUE,
  ];

  // Directly create a placeholder as we need this to be placeholdered
  // regardless if this is a POST or GET request.
  // @todo remove this when https://www.drupal.org/node/2367555 lands.
  return \Drupal::service('render_placeholder_generator')
    ->createPlaceholder($element);
}