1 layout_renderer_standard.inc LayoutRendererStandard::renderBlocks()

Render all prepared blocks, first by dispatching to their plugin's render callback, then handing that output off to the block's style plugin.

Return value

array: The array of rendered blocks, keyed on block UUID.

File

core/modules/layout/plugins/renderers/layout_renderer_standard.inc, line 453

Class

LayoutRendererStandard
The standard render for a Layout display object.

Code

function renderBlocks() {
  $this->rendered['blocks'] = array();

  // Do a pass through all blocks to check for the main system content block.
  // This serves a dual-purpose of rendering the system block first, allowing
  // modifications to other blocks (such as breadcrumb), and it prevents
  // rendering of all other blocks in the event of a 404 or 403 response from
  // the system menu handler.
  foreach ($this->prepared['blocks'] as $uuid => $block) {
    if ($block->module === 'system' && $block->delta === 'main') {
      $system_content = $this->renderBlock($block);
      $response_code = (int) $system_content;
      // If a 404 or 403 skip all rendering and return nothing, as the error
      // page will generate its own replacement content.
      if ($response_code === MENU_NOT_FOUND || $response_code === MENU_ACCESS_DENIED) {
        $this->menu_response = $response_code;
        return array();
      }
    }
  }

  // Render all other blocks.
  foreach ($this->prepared['blocks'] as $uuid => $block) {
    if ($block->module === 'system' && $block->delta === 'main') {
      $this->rendered['blocks'][$uuid] = $system_content;
    }
    elseif ($block->status && $content = $this->renderBlock($block)) {
      $this->rendered['blocks'][$uuid] = $content;
    }
  }

  return $this->rendered['blocks'];
}