/**
  * Builds a structured array representing the fieldable panel pane's content.
  *
  * @param object $entity
  *   A fieldable panel pane entity.
  * @param string $view_mode
  *   View mode, e.g. 'full', 'teaser'...
  * @param string $langcode
  *   (optional) A language code to use for rendering. Defaults to the global
  *   content language of the current request.
  */
 public function buildContent($entity, $view_mode = 'full', $langcode = NULL)
 {
     if (!isset($langcode)) {
         $langcode = $GLOBALS['language_content']->language;
     }
     // Remove previously built content, if exists.
     $entity->content = array();
     // Add the title so that it may be controlled via other display mechanisms.
     $entity->content['title'] = array('#theme' => 'html_tag', '#tag' => 'h2', '#value' => '');
     // Some titles link to a page.
     if (!empty($entity->title)) {
         if (!empty($entity->link) && !empty($entity->path)) {
             $entity->content['title']['#value'] = l($entity->title, $entity->path);
         } else {
             $entity->content['title']['#value'] = check_plain($entity->title);
         }
     }
     // Allow modules to change the view mode, trigger
     // hook_entity_view_mode_alter().
     $context = array('entity_type' => 'fieldable_panels_pane', 'entity' => $entity, 'langcode' => $langcode);
     drupal_alter('entity_view_mode', $view_mode, $context);
     // Build fields content.
     field_attach_prepare_view('fieldable_panels_pane', array($entity->fpid => $entity), $view_mode, $langcode);
     entity_prepare_view('fieldable_panels_pane', array($entity->fpid => $entity), $langcode);
     $entity->content += field_attach_view('fieldable_panels_pane', $entity, $view_mode, $langcode);
     // Allow modules to make their own additions to the entity.
     module_invoke_all('fieldable_panels_pane_view', $entity, $view_mode, $langcode);
     module_invoke_all('entity_view', $entity, 'fieldable_panels_pane', $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);
 }
 public function view($entity, $view_mode = 'full', $langcode = NULL)
 {
     // Allow modules to change the view mode.
     $context = array('entity_type' => 'fieldable_panels_pane', 'entity' => $entity, 'langcode' => $langcode);
     drupal_alter('entity_view_mode', $view_mode, $context);
     // attach our fields and prepare the pane for rendering
     field_attach_prepare_view('fieldable_panels_pane', array($entity->fpid => $entity), $view_mode, $langcode);
     entity_prepare_view('fieldable_panels_pane', array($entity->fpid => $entity), $langcode);
     $build = field_attach_view('fieldable_panels_pane', $entity, $view_mode, $langcode);
     $build += array('#fieldable_panels_pane' => $entity, '#theme' => 'fieldable_panels_pane', '#element' => $entity, '#view_mode' => $view_mode, '#language' => $langcode);
     // Add contextual links for this fieldable panel pane, except when the pane
     // is already being displayed on its own page. Modules may alter this
     // behavior (for example, to restrict contextual links to certain view
     // modes) by implementing hook_fieldable_panels_pane_view_alter().
     if (!empty($entity->fpid) && !($view_mode == 'full' && fieldable_panels_pane_is_page($entity))) {
         $build['#contextual_links']['fieldable_panels_panes'] = array('admin/structure/fieldable-panels-panes/view', array($entity->fpid));
     }
     $entity_type = 'fieldable_panels_pane';
     drupal_alter(array('fieldable_panels_pane_view', 'entity_view'), $build, $entity_type);
     return $build;
 }
 /**
  * Builds a structured array representing the button content.
  *
  * @param object $entity
  *   A button entity.
  * @param string $view_mode
  *   View mode, e.g. 'full', 'teaser'...
  * @param string $langcode
  *   (optional) A language code to use for rendering. Defaults to the global
  *   content language of the current request.
  */
 public function buildContent($entity, $view_mode = 'full', $langcode = NULL)
 {
     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);
 }