You are here

function disable_message_pre_render_debug_output in Disable Messages 8

Same name and namespace in other branches
  1. 7 disable_messages.module \disable_message_pre_render_debug_output()

Pre render function to render the debug output into the page footer.

A separate pre-render function is required because the messages would not yet be processed by the time page_alter is called.

Parameters

string $elements: Elements.

Return value

mixed Return elements.

1 string reference to 'disable_message_pre_render_debug_output'
disable_messages_page_alter in ./disable_messages.module
Implements hook_page_alter().

File

./disable_messages.module, line 242
The disable_messages module file.

Code

function disable_message_pre_render_debug_output(&$elements) {
  $cache_messages = \Drupal::cache()
    ->get('cache_messages');
  $style = '';
  if (\Drupal::config('disable_messages.settings')
    ->get('disable_messages_debug_visible_div') == '0') {
    $style = 'style="display:none;"';
  }
  $elements['#children'] = '<div id="disable_messages-debug-div" ' . $style . '> <pre>' . Html::escape(var_export($cache_messages->data, TRUE)) . '</pre> </div>';
  return $elements;
}