You are here

function eck__entity__view_callback in Entity Construction Kit (ECK) 7.2

Same name and namespace in other branches
  1. 7.3 eck.entity.inc \eck__entity__view_callback()

Entity view callback.

1 string reference to 'eck__entity__view_callback'
eck__entity_type__info in ./eck.entity_type.inc
Generate the entity info for a specific entity.

File

./eck.entity.inc, line 560
All the menus, pages, and functionality related to administering entities.

Code

function eck__entity__view_callback($entities, $view_mode = 'full', $langcode = NULL) {
  $build = array();
  foreach ($entities as $entity) {
    $entity_type_name = $entity
      ->entityType();
    $bundle_name = $entity->type;
    $entity_type = entity_type_load($entity_type_name);
    $bundle = bundle_load($entity_type_name, $bundle_name);
    $entity_view = eck__entity__build($entity_type, $bundle, $entity, $view_mode);
    $property_view = array();
    $formatters = eck_property_behavior_invoke_plugin($entity_type, 'default_formatter', array(
      'entity' => $entity,
    ));
    foreach ($formatters as $property => $formatter) {
      $property_view[$property] = $formatter;
    }
    $entity_id = entity_id($entity_type_name, $entity);
    $entity_view = array_merge($property_view, $entity_view[$entity_type_name][$entity_id]);
    eck_property_behavior_invoke_plugin($entity_type, 'entity_view', array(
      'entity' => $entity,
    ));
    $build[$entity_type_name][$entity_id] = $entity_view;
  }
  return $build;
}