function CommentStatistics::getMaximumCount

Same name and namespace in other branches
  1. 8.9.x core/modules/comment/src/CommentStatistics.php \Drupal\comment\CommentStatistics::getMaximumCount()
  2. 10 core/modules/comment/src/CommentStatistics.php \Drupal\comment\CommentStatistics::getMaximumCount()
  3. 11.x core/modules/comment/src/CommentStatistics.php \Drupal\comment\CommentStatistics::getMaximumCount()

Find the maximum number of comments for the given entity type.

Used to influence search rankings.

Parameters

string $entity_type: The entity type to consider when fetching the maximum comment count for.

Return value

int The maximum number of comments for and entity of the given type.

Overrides CommentStatisticsInterface::getMaximumCount

File

core/modules/comment/src/CommentStatistics.php, line 156

Class

CommentStatistics

Namespace

Drupal\comment

Code

public function getMaximumCount($entity_type) {
    return $this->database
        ->query('SELECT MAX([comment_count]) FROM {comment_entity_statistics} WHERE [entity_type] = :entity_type', [
        ':entity_type' => $entity_type,
    ])
        ->fetchField();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.