Comment::getOwner

public Comment::getOwner()

Returns the entity owner's user entity.

Return value

\Drupal\user\UserInterface The owner user entity.

Overrides EntityOwnerInterface::getOwner

File

core/modules/comment/src/Entity/Comment.php, line 523

Class

Comment
Defines the comment entity class.

Namespace

Drupal\comment\Entity

Code

1
2
3
4
5
6
7
8
9
public function getOwner() {
  $user = $this->get('uid')->entity;
  if (!$user || $user->isAnonymous()) {
    $user = User::getAnonymousUser();
    $user->name = $this->getAuthorName();
    $user->homepage = $this->getHomepage();
  }
  return $user;
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.