Prepares a user account object for rendering comment authors.
This helper handles anonymous authors in addition to registered comment authors.
\Drupal\user\Plugin\Core\Entity\User A user account, for use with theme_username() or the user_picture template.
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();
}