You are here

function entity_build_content in Entity API 7

Builds a structured array representing the entity's content.

The content built for the entity will vary depending on the $view_mode parameter.

Note: Currently, this only works for entity types provided with the entity CRUD API.

Parameters

$entity_type: The type of the entity.

$entity: An entity object.

$view_mode: A view mode as used by this entity type, e.g. 'full', 'teaser'...

$langcode: (optional) A language code to use for rendering. Defaults to the global content language of the current request.

Return value

array The renderable array.

1 call to entity_build_content()
EntityAPIController::view in includes/entity.controller.inc
Implements EntityAPIControllerInterface.

File

./entity.module, line 565

Code

function entity_build_content($entity_type, $entity, $view_mode = 'full', $langcode = NULL) {
  $info = entity_get_info($entity_type);
  if (method_exists($entity, 'buildContent')) {
    return $entity
      ->buildContent($view_mode, $langcode);
  }
  elseif (in_array('EntityAPIControllerInterface', class_implements($info['controller class']))) {
    return entity_get_controller($entity_type)
      ->buildContent($entity, $view_mode, $langcode);
  }
}