function Comment::getAuthorName
Same name in other branches
- 9 core/modules/comment/src/Entity/Comment.php \Drupal\comment\Entity\Comment::getAuthorName()
- 8.9.x core/modules/comment/src/Entity/Comment.php \Drupal\comment\Entity\Comment::getAuthorName()
- 10 core/modules/comment/src/Entity/Comment.php \Drupal\comment\Entity\Comment::getAuthorName()
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 406
Class
- Comment
- Defines the comment entity class.
Namespace
Drupal\comment\EntityCode
public function getAuthorName() {
// If their is a valid user id and the user entity exists return the label.
if ($this->get('uid')->target_id && $this->get('uid')->entity) {
return $this->get('uid')->entity
->label();
}
return $this->get('name')->value ?: \Drupal::config('user.settings')->get('anonymous');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.