function CommentStorage::getMaxThread

Same name in other branches
  1. 9 core/modules/comment/src/CommentStorage.php \Drupal\comment\CommentStorage::getMaxThread()
  2. 8.9.x core/modules/comment/src/CommentStorage.php \Drupal\comment\CommentStorage::getMaxThread()
  3. 11.x core/modules/comment/src/CommentStorage.php \Drupal\comment\CommentStorage::getMaxThread()

Overrides CommentStorageInterface::getMaxThread

File

core/modules/comment/src/CommentStorage.php, line 82

Class

CommentStorage
Defines the storage handler class for comments.

Namespace

Drupal\comment

Code

public function getMaxThread(CommentInterface $comment) {
    $query = $this->database
        ->select($this->getDataTable(), 'c')
        ->condition('entity_id', $comment->getCommentedEntityId())
        ->condition('field_name', $comment->getFieldName())
        ->condition('entity_type', $comment->getCommentedEntityTypeId())
        ->condition('default_langcode', 1);
    $query->addExpression('MAX([thread])', 'thread');
    return $query->execute()
        ->fetchField();
}

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