You are here

public function ButtonController::view in Command Buttons 7

Implements EntityAPIControllerInterface.

Overrides EntityAPIControllerExportable::view

File

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

Class

ButtonController
Entity controller class.

Code

public function view($entities, $view_mode = 'full', $langcode = NULL, $page = NULL) {
  if (!isset($langcode)) {
    $langcode = $GLOBALS['language_content']->language;
  }

  // Ensure entities is an array.
  if (!is_array($entities)) {
    $entities = array(
      $entities,
    );
  }
  $build = array();
  foreach ($entities as $entity) {

    // Populate $entity->content with a render() array.
    $this
      ->buildContent($entity, $view_mode, $langcode);

    // Allow modules to modify the structured button.
    $type = 'command_button';
    drupal_alter(array(
      'command_buttons_view',
      'entity_view',
    ), $entity->content, $type);
    $build[] = $entity->content;

    // We don't need duplicate rendering info in $entity->content.
    unset($entity->content);
  }
  return $build;
}