W3cubDocs

/Drupal 8

public function HtmlRenderer::buildPageTopAndBottom

public HtmlRenderer::buildPageTopAndBottom(array &$html)

Invokes the page top and bottom hooks.

@internal

Parameters

array &$html: A #type 'html' render array, for which the page top and bottom hooks will be invoked, and to which the 'page_top' and 'page_bottom' children (also render arrays) will be added (if non-empty).

Throws

\LogicException

See also

hook_page_top()

hook_page_bottom()

html.html.twig

File

core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php, line 330

Class

HtmlRenderer
Default main content renderer for HTML requests.

Namespace

Drupal\Core\Render\MainContent

Code

public function buildPageTopAndBottom(array &$html) {
  // Modules can add render arrays to the top and bottom of the page.
  $page_top = [];
  $page_bottom = [];
  foreach ($this->moduleHandler->getImplementations('page_top') as $module) {
    $function = $module . '_page_top';
    $function($page_top);
  }
  foreach ($this->moduleHandler->getImplementations('page_bottom') as $module) {
    $function = $module . '_page_bottom';
    $function($page_bottom);
  }
  if (!empty($page_top)) {
    $html['page_top'] = $page_top;
  }
  if (!empty($page_bottom)) {
    $html['page_bottom'] = $page_bottom;
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!MainContent!HtmlRenderer.php/function/HtmlRenderer::buildPageTopAndBottom/8.1.x