You are here

public function CommentUserSignature::build in Display Suite 8.4

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

Renders a field.

Return value

array A renderable array representing the content of the field.

Overrides Markup::build

File

src/Plugin/DsField/Comment/CommentUserSignature.php, line 23

Class

CommentUserSignature
Plugin that renders the user signature of a comment.

Namespace

Drupal\ds\Plugin\DsField\Comment

Code

public function build() {
  $comment = $this
    ->entity();
  $user_id = $comment->uid->target_id;
  $user = User::load($user_id);
  $key = $this
    ->key();
  if (isset($user->{$key}->value)) {
    $format = $this
      ->format();
    return [
      '#type' => 'processed_text',
      '#text' => $user->{$key}->value,
      '#format' => $user->{$format}->value,
      '#filter_types_to_skip' => [],
      '#langcode' => '',
    ];
  }
  return [];
}