diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 5f6f906..2aac59d 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -727,6 +727,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. @@ -760,7 +761,7 @@ function template_preprocess_comment(&$variables) { else { $uri = $comment->urlInfo(); $attributes = $uri->getOption('attributes') ?: array(); - $attributes += array('class' => array('permalink'), 'rel' => 'bookmark'); + $attributes += array('rel' => 'bookmark'); $uri->setOption('attributes', $attributes); $variables['title'] = \Drupal::linkGenerator()->generateFromUrl($comment->getSubject(), $uri); @@ -819,28 +820,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 575510f..2d3d13e 100644 --- a/core/modules/comment/templates/comment.html.twig +++ b/core/modules/comment/templates/comment.html.twig @@ -64,7 +64,17 @@ * @ingroup themeable */ #} - +{% + set classes = [ + 'comment', + status != 'published' ? status, + status != 'preview' ? 'permalink', + not author_id ? 'by-anonymous', + author_id == commented_entity.getOwnerId() ? 'by-' ~ commented_entity.getEntityTypeId() ~ '-author', + 'clearfix', + ] +%} + {% if title %} {{ title_prefix }} {% endif %} @@ -98,7 +108,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 7a22fc0..f80d4b0 100644 --- a/core/themes/bartik/templates/comment.html.twig +++ b/core/themes/bartik/templates/comment.html.twig @@ -62,7 +62,17 @@ * @see template_preprocess_comment() */ #} -
+{% + set classes = [ + 'comment', + status != 'published' ? status, + status != 'preview' ? 'permalink', + not author_id ? 'by-anonymous', + author_id == commented_entity.getOwnerId() ? 'by-' ~ commented_entity.getEntityTypeId() ~ '-author', + 'clearfix', + ] +%} +
@@ -108,7 +118,7 @@ {{ title_suffix }} {% endif %} - + {{ content|without('links') }}