$count_query->
addExpression('COUNT(*)'
);
$count_query ->
condition('c.entity_id',
$entity->
id()) ->
condition('c.entity_type',
$entity->
getEntityTypeId()) ->
condition('c.field_name',
$field_name) ->
condition('c.default_langcode', 1
) ->
addTag('entity_access'
) ->
addTag('comment_filter'
) ->
addMetaData('base_table', 'comment'
) ->
addMetaData('entity',
$entity) ->
addMetaData('field_name',
$field_name);
$query->
setCountQuery($count_query);
} if (!
$this->currentUser->
hasPermission('administer comments'
)) { $query->
condition('c.status', CommentInterface::PUBLISHED
);
if ($comments_per_page) { $count_query->
condition('c.status', CommentInterface::PUBLISHED
);
} } if ($mode == CommentManagerInterface::COMMENT_MODE_FLAT
) { $query->
orderBy('c.cid', 'ASC'
);
}