You are here

protected function BlockController::render in Render cache 7.2

Render uncached objects.

This function needs to be implemented by every child class.

Parameters

array $objects: Array of $objects to be rendered keyed by id.

Return value

array Render array keyed by id.

Overrides AbstractBaseController::render

File

modules/controller/render_cache_block/src/RenderCache/Controller/BlockController.php, line 115
Contains \Drupal\render_cache_block\RenderCache\Controller\BlockController

Class

BlockController
BlockController - Provides render caching for block objects.

Namespace

Drupal\render_cache_block\RenderCache\Controller

Code

protected function render(array $objects) {

  // Helper variables.
  $blocks = $objects;

  // Ensure block module is loaded.
  module_load_include('module', 'block', 'block');

  // Turn off core block caching.
  foreach ($blocks as $block) {
    $block->cache = DRUPAL_NO_CACHE;
  }

  // This works because _block_render_blocks uses the same format for the
  // $id of the block in the array.
  $list = _block_render_blocks($blocks);
  $build = array();
  if ($list) {
    $build = _block_get_renderable_array($list);
  }
  return $build;
}