Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Comment.php

function Comment::getOwner

Overrides EntityOwnerTrait::getOwner

File

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

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal