public function CommentUser::build in Display Suite 8.3
Same name and namespace in other branches
- 8.4 src/Plugin/DsField/Comment/CommentUser.php \Drupal\ds\Plugin\DsField\Comment\CommentUser::build()
- 8.2 src/Plugin/DsField/Comment/CommentUser.php \Drupal\ds\Plugin\DsField\Comment\CommentUser::build()
Renders a field.
Return value
array A renderable array representing the content of the field.
Overrides DsFieldBase::build
File
- src/
Plugin/ DsField/ Comment/ CommentUser.php, line 54
Class
- CommentUser
- Plugin that renders a view mode.
Namespace
Drupal\ds\Plugin\DsField\CommentCode
public function build() {
$view_mode = $this
->getEntityViewMode();
/* @var $comment \Drupal\comment\CommentInterface */
$comment = $this
->entity();
$uid = $comment
->getOwnerId();
$user = $this->entityTypeManager
->getStorage('user')
->load($uid);
$build = [];
if ($user) {
$build = $this->entityTypeManager
->getViewBuilder('user')
->view($user, $view_mode);
}
return $build;
}