You are here

public function ButtonController::buildContent in Command Buttons 7

Builds a structured array representing the button content.

Parameters

object $entity: A button entity.

string $view_mode: View mode, e.g. 'full', 'teaser'...

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

Overrides EntityAPIController::buildContent

1 call to ButtonController::buildContent()
ButtonController::view in includes/ButtonController.class.php
Implements EntityAPIControllerInterface.

File

includes/ButtonController.class.php, line 123
Contains the controller class for the OA Button entity.

Class

ButtonController
Entity controller class.

Code

public function buildContent($entity, $view_mode = 'full', $langcode = NULL, $content = array()) {
  if (!isset($langcode)) {
    $langcode = $GLOBALS['language_content']->language;
  }

  // Remove previously built content, if exists.
  $entity->content = array();

  // Allow modules to change the view mode.
  $context = array(
    'entity_type' => 'command_button',
    'entity' => $entity,
    'langcode' => $langcode,
  );
  drupal_alter('entity_view_mode', $view_mode, $context);

  // Build fields content.
  field_attach_prepare_view('command_button', array(
    $entity->bid => $entity,
  ), $view_mode, $langcode);
  entity_prepare_view('command_button', array(
    $entity->bid => $entity,
  ), $langcode);
  $entity->content += field_attach_view('command_button', $entity, $view_mode, $langcode);

  // Allow modules to make their own additions to the entity.
  module_invoke_all('command_button_view', $entity, $view_mode, $langcode);
  module_invoke_all('entity_view', $entity, 'command_button', $view_mode, $langcode);

  // Make sure the current view mode is stored if no module has already
  // populated the related key.
  $entity->content += array(
    '#view_mode' => $view_mode,
  );
}