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

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
2016-10-29 08:50:21
Comments
Leave a Comment

Please login to continue.