function sarnia_view in Sarnia 7
Build a Render API array from a Sarnia entity.
@TODO SarniaController should implement EntityAPIControllerInterface, and this should live in SarniaController::view()
See also
2 calls to sarnia_view()
- sarnia_entity_page in ./
sarnia.module - Menu page callback to display a Sarnia entity.
- sarnia_view_multiple in ./
sarnia.module
File
- ./
sarnia.module, line 936
Code
function sarnia_view(&$entity, $view_mode = 'default', $langcode = NULL) {
if (!isset($langcode)) {
$langcode = $GLOBALS['language_content']->language;
}
// Build field output in $entity->content.
sarnia_build_content($entity, $view_mode, $langcode);
// Initialize the render array.
$build = $entity->content;
// Remove the render array from the entity, so that it only appears once.
unset($entity->content);
// Add basic info to the render array.
$build += array(
'#theme' => 'sarnia_entity',
'#entity' => $entity,
'#view_mode' => $view_mode,
'#language' => $langcode,
);
// Invoke hook_entity_view_alter().
drupal_alter('entity_view', $build, $entity->type);
return $build;
}