You are here

function bootstrap_site_alert_page_top in Bootstrap Site Alert 8.2

Same name and namespace in other branches
  1. 8 bootstrap_site_alert.module \bootstrap_site_alert_page_top()

Implements hook_page_top().

File

./bootstrap_site_alert.module, line 18
The bootstrap_site_alert module file.

Code

function bootstrap_site_alert_page_top(array &$page_top) {

  // Render our alert.
  $view = Views::getView('bootstrap_site_alert');
  $render_array = $view
    ->buildRenderable('bootstrap_site_alert_block');
  $render = \Drupal::service('renderer')
    ->renderPlain($render_array);
  if (!empty($render)) {
    $page_top['bootstrap_site_alert'] = [
      '#type' => 'inline_template',
      '#template' => Html::decodeEntities($render
        ->__toString()),
      '#weight' => 1000,
      '#cache' => $render_array['#cache'],
    ];
  }
}