function CommentManager::getCountNewComments

Returns the number of new comments on a given entity for the current user.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity to which the comments are attached to.

string $field_name: (optional) The field_name to count comments for. Defaults to any field.

int $timestamp: (optional) Time to count from. Defaults to time of last user access the entity.

Return value

int|false The number of new comments or FALSE if the user is not authenticated or if the History module is not installed.

Overrides CommentManagerInterface::getCountNewComments

File

core/modules/comment/src/CommentManager.php, line 198

Class

CommentManager
Comment manager contains common functions to manage comment fields.

Namespace

Drupal\comment

Code

public function getCountNewComments(EntityInterface $entity, $field_name = NULL, $timestamp = 0) {
  @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Use \\Drupal\\history\\HistoryManager::getCountNewComments() instead. See https://www.drupal.org/project/drupal/issues/3551729', 'E_USER_DEPRECATED');
  if (!$this->moduleHandler
    ->moduleExists('history')) {
    return FALSE;
  }
  return \Drupal::service('Drupal\\history\\HistoryManager')->getCountNewComments($entity, $field_name, $timestamp);
}

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