You are here

public function CommentStorage::getMaxThreadPerThread in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/comment/src/CommentStorage.php \Drupal\comment\CommentStorage::getMaxThreadPerThread()
  2. 10 core/modules/comment/src/CommentStorage.php \Drupal\comment\CommentStorage::getMaxThreadPerThread()

Gets the maximum encoded thread value for the children of this comment.

Parameters

\Drupal\comment\CommentInterface $comment: A comment entity.

Return value

string The maximum encoded thread value among all replies of $comment.

Overrides CommentStorageInterface::getMaxThreadPerThread

File

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

Class

CommentStorage
Defines the storage handler class for comments.

Namespace

Drupal\comment

Code

public function getMaxThreadPerThread(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('thread', $comment
    ->getParentComment()
    ->getThread() . '.%', 'LIKE')
    ->condition('default_langcode', 1);
  $query
    ->addExpression('MAX([thread])', 'thread');
  return $query
    ->execute()
    ->fetchField();
}