diff --git a/core/modules/comment/src/Plugin/Field/FieldFormatter/AuthorNameFormatter.php b/core/modules/comment/src/Plugin/Field/FieldFormatter/AuthorNameFormatter.php index 2cf5cec..d6d36b4 100644 --- a/core/modules/comment/src/Plugin/Field/FieldFormatter/AuthorNameFormatter.php +++ b/core/modules/comment/src/Plugin/Field/FieldFormatter/AuthorNameFormatter.php @@ -34,12 +34,7 @@ public function viewElements(FieldItemListInterface $items) { foreach ($items as $delta => $item) { /** @var $comment \Drupal\comment\CommentInterface */ $comment = $item->getEntity(); - $account = $comment->getOwner(); - if ($account->isAnonymous()) { - $account->setUsername($comment->getAuthorName()); - $account->setEmail($comment->getAuthorEmail()); - $account->homepage = $comment->getHomepage(); - } + $account = comment_prepare_author($comment); $elements[$delta] = array( '#theme' => 'username', '#account' => $account, @@ -56,7 +51,7 @@ public function viewElements(FieldItemListInterface $items) { * {@inheritdoc} */ public static function isApplicable(FieldDefinitionInterface $field_definition) { - return $field_definition->getName() === 'name'; + return $field_definition->getName() === 'name' && $field_definition->getTargetEntityTypeId() === 'comment'; } }