function comment_prepare_author

Prepares a user account object for rendering comment authors.

This helper handles anonymous authors in addition to registered comment authors.

Return value

\Drupal\user\Plugin\Core\Entity\User A user account, for use with theme_username() or the user_picture template.

2 calls to comment_prepare_author()
comment_admin_overview in drupal/core/modules/comment/comment.admin.inc
Form constructor for the comment overview administration form.
template_preprocess_comment in drupal/core/modules/comment/comment.module
Prepares variables for comment templates.

File

drupal/core/modules/comment/comment.module, line 1516
Enables users to comment on published content.

Code

function comment_prepare_author(Comment $comment) {

  // The account has been pre-loaded by CommentRenderController::buildContent().
  $account = $comment->uid->entity;
  if (!$account) {
    $account = entity_create('user', array(
      'uid' => 0,
      'name' => $comment->name->value,
      'homepage' => $comment->homepage->value,
    ));
  }
  return $account
    ->getBCEntity();
}