Commit 6d83d842 authored by Dmytrii Kaiun's avatar Dmytrii Kaiun Committed by Andrii Chyrskyi
Browse files

Issue #3259745 by tBKoT: Use commen_count property instead of function

parent 1d7163ce
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -109,6 +109,9 @@ function _socialbase_get_join_method_icon($title) {

/**
 * Get comment count for a node.
 *
 * @deprecated
 * Use $entity->get(<comment_field_name>)->comment_count instead this function.
 */
function _socialbase_node_get_comment_count(NodeInterface $node) {
  $comment_count = &drupal_static(__FUNCTION__ . $node->id());
+1 −1
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ class Field extends PreprocessBase {
      $node = !empty($attached['#object']) ? $attached['#object'] : NULL;
      // Count the amount of comments placed on a Node..
      if ($node instanceof Node) {
        $comment_count = _socialbase_node_get_comment_count($node);
        $comment_count = (int) $node->get($element['#field_name'])->comment_count;
        // Add it to the title.
        $variables['comment_count'] = $comment_count;

+1 −1
Original line number Diff line number Diff line
@@ -173,7 +173,7 @@ class Node extends PreprocessBase {
      // OPEN or CLOSED we can render icon for
      // comment count, and add the comment count to the node.
      if ($node->$comment_field_name->status != CommentItemInterface::HIDDEN) {
        $comment_count = _socialbase_node_get_comment_count($node);
        $comment_count = (int) $node->get($comment_field_name)->comment_count;
        $variables['below_content'][$comment_field_name]['#title'] = $comment_count === 0 ? t('Be the first one to comment') : t('Comments');

        // If it's closed, we only show the comment section when there are