You are here

protected function EntityController::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_entity/src/RenderCache/Controller/EntityController.php, line 95
Contains \Drupal\render_cache_entity\RenderCache\Controller\EntityController

Class

EntityController
EntityController - Provides render caching for entity objects.

Namespace

Drupal\render_cache_entity\RenderCache\Controller

Code

protected function render(array $objects) {

  // Helper variables.
  $entities = $objects;
  $view_mode = $this->context['view_mode'];
  $langcode = $this->context['langcode'];
  $entity_type = $this->context['entity_type'];
  $entity_info = entity_get_info($entity_type);

  // If this is a entity view callback.
  if (isset($entity_info['render cache storage']['callback'])) {
    $build = $entity_info['render cache storage']['callback']($entities, $view_mode, $langcode, $entity_type);
  }
  else {
    $page = $this
      ->getPageArgument();
    $build = entity_get_controller($entity_type)
      ->view($entities, $view_mode, $langcode, $page);
  }
  $build = reset($build);
  return $build;
}