You are here

public function Comment::getAuthorName in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/comment/src/Entity/Comment.php \Drupal\comment\Entity\Comment::getAuthorName()

Returns the comment author's name.

For anonymous authors, this is the value as typed in the comment form.

Return value

string The name of the comment author.

Overrides CommentInterface::getAuthorName

1 call to Comment::getAuthorName()
Comment::getOwner in core/modules/comment/src/Entity/Comment.php
Returns the entity owner's user entity.

File

core/modules/comment/src/Entity/Comment.php, line 415
Contains \Drupal\comment\Entity\Comment.

Class

Comment
Defines the comment entity class.

Namespace

Drupal\comment\Entity

Code

public function getAuthorName() {
  if ($this
    ->get('uid')->target_id) {
    return $this
      ->get('uid')->entity
      ->label();
  }
  return $this
    ->get('name')->value ?: \Drupal::config('user.settings')
    ->get('anonymous');
}