You are here

public function MerciDefaultEntityController::buildContent in MERCI (Manage Equipment Reservations, Checkout and Inventory) 7.3

Builds a structured array representing the entity's content.

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

Parameters

$entity: An entity object.

$view_mode: View mode, 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

The renderable array.

Overrides EntityAPIControllerInterface::buildContent

File

merci_line_item/includes/merci_line_item.controller.inc, line 328
Provides a central controller for Drupal Commerce.

Class

MerciDefaultEntityController
@file Provides a central controller for Drupal Commerce.

Code

public function buildContent($entity, $view_mode = 'full', $langcode = NULL, $content = array()) {

  // Remove previously built content, if exists.
  $entity->content = $content;
  $langcode = isset($langcode) ? $langcode : $GLOBALS['language_content']->language;

  // Add in fields.
  if (!empty($this->entityInfo['fieldable'])) {
    $entity->content += field_attach_view($this->entityType, $entity, $view_mode, $langcode);
  }

  // Invoke hook_ENTITY_view() to allow modules to add their additions.
  if (function_exists('rules_invoke_all')) {
    rules_invoke_all($this->entityType . '_view', $entity, $view_mode, $langcode);
  }

  // Invoke the more generic hook_entity_view() to allow the same.
  module_invoke_all('entity_view', $entity, $this->entityType, $view_mode, $langcode);

  // Remove the build array information from the entity and return it.
  $build = $entity->content;
  unset($entity->content);
  return $build;
}