You are here

public function DrupalCommerceEntityController::buildContent in Commerce Core 7

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

2 calls to DrupalCommerceEntityController::buildContent()
CommercePaymentTransactionEntityController::buildContent in modules/payment/includes/commerce_payment_transaction.controller.inc
Builds a structured array representing the entity's content.
CommerceProductEntityController::buildContent in modules/product/includes/commerce_product.controller.inc
Builds a structured array representing the entity's content.
2 methods override DrupalCommerceEntityController::buildContent()
CommercePaymentTransactionEntityController::buildContent in modules/payment/includes/commerce_payment_transaction.controller.inc
Builds a structured array representing the entity's content.
CommerceProductEntityController::buildContent in modules/product/includes/commerce_product.controller.inc
Builds a structured array representing the entity's content.

File

includes/commerce.controller.inc, line 368
Provides a central controller for Drupal Commerce.

Class

DrupalCommerceEntityController
Default implementation of DrupalCommerceEntityControllerInterface.

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.
  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;
}