1 comment.entity.inc public CommentStorageController::buildContent(EntityInterface $comment, $view_mode = 'full', $langcode = NULL)

Implements EntityControllerInterface::buildContent().

Overrides DefaultEntityController::buildContent

File

core/modules/comment/comment.entity.inc, line 449
Entity controller and class for comments.

Class

CommentStorageController
Defines the controller class for comments.

Code

public function buildContent(EntityInterface $comment, $view_mode = 'full', $langcode = NULL) {
  global $language_content;
  $langcode = $langcode ? $langcode : $language_content->langcode;

  $node = node_load($comment->nid);

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

  // Allow modules to change the display mode.
  $view_mode = key(entity_view_mode_prepare('comment', array($comment->cid => $comment), $view_mode, $langcode));

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

  $comment->content['links'] = array(
    '#theme' => 'links__comment',
    '#pre_render' => array('backdrop_pre_render_links'),
    '#attributes' => array('class' => array('links', 'inline')),
  );
  if (empty($comment->in_preview)) {
    $comment->content['links']['comment'] = array(
      '#theme' => 'links__comment__comment',
      '#links' => comment_links($comment, $node),
      '#attributes' => array('class' => array('links', 'inline')),
    );
  }

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

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