1 entity.controller.inc public DefaultEntityController::view($entities, $view_mode = 'full', $langcode = NULL, $page = NULL)

Implements EntityControllerInterface::view().

Overrides EntityControllerInterface::view

File

core/modules/entity/entity.controller.inc, line 608
Entity API controller classes and interface.

Class

DefaultEntityController
Defines a base entity controller class.

Code

public function view($entities, $view_mode = 'full', $langcode = NULL, $page = NULL) {
  global $language_content;
  $langcode = $langcode ? $langcode : $language_content->langcode;
  // @todo ensure entities are keyed by entity id.
  if (!empty($this->entityInfo['fieldable'])) {
    field_attach_prepare_view($this->entityType, $entities, $view_mode);
  }
  entity_prepare_view($this->entityType, $entities);

  $view = array();
  foreach ($entities as $entity) {
    /* @var EntityInterface $entity */
    $this->buildContent($entity, $view_mode, $langcode);

    $build = $entity->content;
    // We don't need duplicate rendering info in entity->content.
    unset($entity->content);

    $build += array(
      // @see template_preprocess_entity()
      '#theme' => 'entity',
      '#entity_type' => $this->entityType,
      '#entity' => $entity,
      '#view_mode' => $view_mode,
      '#language' => $langcode,
      '#page' => $page,
    );
    // Allow modules to modify the structured entity.
    backdrop_alter(array($this->entityType . '_view', 'entity_view'), $build, $this->entityType);

    $view[$this->entityType][$entity->id()] = $build;
  }

  return $view;
}