public function EntityAPIController::view in Entity API 7
Implements EntityAPIControllerInterface.
Overrides EntityAPIControllerInterface::view
1 call to EntityAPIController::view()
- EntityAPIControllerExportable::view in includes/
entity.controller.inc - Implements EntityAPIControllerInterface.
1 method overrides EntityAPIController::view()
- EntityAPIControllerExportable::view in includes/
entity.controller.inc - Implements EntityAPIControllerInterface.
File
- includes/
entity.controller.inc, line 656 - Provides a controller building upon the core controller but providing more features like full CRUD functionality.
Class
- EntityAPIController
- A controller implementing EntityAPIControllerInterface for the database.
Code
public function view($entities, $view_mode = 'full', $langcode = NULL, $page = NULL) {
// For Field API and entity_prepare_view, the entities have to be keyed by
// (numeric) id.
$entities = entity_key_array_by_property($entities, $this->idKey);
if (!empty($this->entityInfo['fieldable'])) {
field_attach_prepare_view($this->entityType, $entities, $view_mode);
}
entity_prepare_view($this->entityType, $entities);
$langcode = isset($langcode) ? $langcode : $GLOBALS['language_content']->language;
$view = array();
foreach ($entities as $entity) {
$build = entity_build_content($this->entityType, $entity, $view_mode, $langcode);
$build += array(
// If the entity type provides an implementation, use this instead the
// generic one.
// @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.
drupal_alter(array(
$this->entityType . '_view',
'entity_view',
), $build, $this->entityType);
$key = isset($entity->{$this->idKey}) ? $entity->{$this->idKey} : NULL;
$view[$this->entityType][$key] = $build;
}
return $view;
}