You are here

function _socialbase_node_get_comment_count in Open Social 8

Same name and namespace in other branches
  1. 8.9 themes/socialbase/socialbase.theme \_socialbase_node_get_comment_count()
  2. 8.2 themes/socialbase/socialbase.theme \_socialbase_node_get_comment_count()
  3. 8.3 themes/socialbase/socialbase.theme \_socialbase_node_get_comment_count()
  4. 8.4 themes/socialbase/socialbase.theme \_socialbase_node_get_comment_count()
  5. 8.5 themes/socialbase/socialbase.theme \_socialbase_node_get_comment_count()
  6. 8.6 themes/socialbase/socialbase.theme \_socialbase_node_get_comment_count()
  7. 8.7 themes/socialbase/socialbase.theme \_socialbase_node_get_comment_count()
  8. 8.8 themes/socialbase/socialbase.theme \_socialbase_node_get_comment_count()

Get comment count for a node.

1 call to _socialbase_node_get_comment_count()
Node::preprocessElement in themes/socialbase/src/Plugin/Preprocess/Node.php
Preprocess the variables array if an element is present.

File

themes/socialbase/socialbase.theme, line 82
The primary PHP file for the Social base theme.

Code

function _socialbase_node_get_comment_count(Node $node, $comment_field_name) {
  $count = 0;
  $comment_count = $node->{$comment_field_name}->comment_count;
  if ($comment_count) {
    $count = $comment_count;
  }
  return $count;
}