diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index bdf53bf7db7bcfdbe84031283218e9cd85ac3991..0ee6f4c3f0d805af26fb901938b5c1516b016906 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -698,6 +698,7 @@ function template_preprocess_comment(&$variables) { '#account' => $account, ); $variables['author'] = drupal_render($username); + $variables['author_id'] = $comment->getOwnerId(); $variables['new_indicator_timestamp'] = $comment->getChangedTime(); $variables['created'] = format_date($comment->getCreatedTime()); // Avoid calling format_date() twice on the same timestamp. @@ -790,28 +791,8 @@ function template_preprocess_comment(&$variables) { $variables['status'] = $comment->isPublished() ? 'published' : 'unpublished'; } - // Gather comment classes. - $variables['attributes']['class'][] = 'comment'; - // 'published' class is not needed, it is either 'preview' or 'unpublished'. - if ($variables['status'] != 'published') { - $variables['attributes']['class'][] = $variables['status']; - } - if (!$comment->getOwnerId()) { - $variables['attributes']['class'][] = 'by-anonymous'; - } - else { - // @todo Use $entity->getAuthorId() after https://drupal.org/node/2078387 - if ($commented_entity instanceof EntityOwnerInterface && $comment->getOwnerId() == $commented_entity->getOwnerId()) { - $variables['attributes']['class'][] = 'by-' . $commented_entity->getEntityTypeId() . '-author'; - } - } - // Add clearfix class. - $variables['attributes']['class'][] = 'clearfix'; - // Add comment author user ID. Necessary for the comment-by-viewer library. $variables['attributes']['data-comment-user-id'] = $comment->getOwnerId(); - - $variables['content_attributes']['class'][] = 'content'; } /** diff --git a/core/modules/comment/templates/comment.html.twig b/core/modules/comment/templates/comment.html.twig index 801f9a6c5844e95bfe91f9e9a3c1e4c4db0bc728..24dbd079627bb40f256b4162249d6f33da9d156f 100644 --- a/core/modules/comment/templates/comment.html.twig +++ b/core/modules/comment/templates/comment.html.twig @@ -66,7 +66,16 @@ * @ingroup themeable */ #} - +{% + set classes = [ + 'comment', + status != 'published' ? status, + not author_id ? 'by-anonymous', + author_id and author_id == commented_entity.getOwnerId() ? 'by-' ~ commented_entity.getEntityTypeId() ~ '-author', + 'clearfix', + ] +%} + {% if title %} {{ title_prefix }} {% endif %} @@ -100,7 +109,7 @@ {{ permalink }} - + {{ content|without('links') }} {% if signature %} diff --git a/core/themes/bartik/templates/comment.html.twig b/core/themes/bartik/templates/comment.html.twig index c5c0a7a905bd240b09de2e831212fea4efe396d9..0fa199146bdae715590d1774d9415dc513b99158 100644 --- a/core/themes/bartik/templates/comment.html.twig +++ b/core/themes/bartik/templates/comment.html.twig @@ -64,7 +64,16 @@ * @see template_preprocess_comment() */ #} -
+{% + set classes = [ + 'comment', + status != 'published' ? status, + not author_id ? 'by-anonymous', + author_id and author_id == commented_entity.getOwnerId() ? 'by-' ~ commented_entity.getEntityTypeId() ~ '-author', + 'clearfix', + ] +%} +
@@ -110,7 +119,7 @@ {{ title_suffix }} {% endif %} - + {{ content|without('links') }}