You are here

public function CommentUser::build in Display Suite 8.2

Same name and namespace in other branches
  1. 8.4 src/Plugin/DsField/Comment/CommentUser.php \Drupal\ds\Plugin\DsField\Comment\CommentUser::build()
  2. 8.3 src/Plugin/DsField/Comment/CommentUser.php \Drupal\ds\Plugin\DsField\Comment\CommentUser::build()

Renders a field.

Overrides DsFieldBase::build

File

src/Plugin/DsField/Comment/CommentUser.php, line 22

Class

CommentUser
Plugin that renders a view mode.

Namespace

Drupal\ds\Plugin\DsField\Comment

Code

public function build() {
  $view_mode = $this
    ->getEntityViewMode();

  /* @var $comment \Drupal\comment\CommentInterface */
  $comment = $this
    ->entity();
  $uid = $comment
    ->getOwnerId();
  $user = entity_load('user', $uid);
  $build = entity_view($user, $view_mode);
  return $build;
}