You are here

function eck__entity__build in Entity Construction Kit (ECK) 7

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

Get the entities view

Parameters

$entity_type: (String) entity type

$id: (int) The entities id

1 call to eck__entity__build()
eck__entity__view in ./eck.entity.inc
Creates a renderable array to show an entity

File

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

Code

function eck__entity__build($entity_type, $bundle, $id) {
  if (is_numeric($id)) {
    $entities = entity_load($entity_type->name, array(
      $id,
    ));
    if (array_key_exists($id, $entities)) {
      $entity = $entities[$id];
    }
    else {
      $entity = NULL;
    }
  }
  else {
    drupal_not_found();
    exit;
  }
  if (!$entity) {
    drupal_not_found();
    exit;
  }
  else {
    if ($entity->type == $bundle->name) {
      return $entity
        ->view();
    }
    else {
      drupal_not_found();
      exit;
    }
  }
}