3 namespace Drupal\comment;
5 use Drupal\Core\Entity\FieldableEntityInterface;
6 use Drupal\Core\Entity\EntityInterface;
9 * Provides an interface for storing and retrieving comment statistics.
11 interface CommentStatisticsInterface {
14 * Returns an array of ranking information for hook_ranking().
17 * Array of ranking information as expected by hook_ranking().
20 * @see comment_ranking()
22 public function getRankingInfo();
25 * Read comment statistics records for an array of entities.
27 * @param \Drupal\Core\Entity\EntityInterface[] $entities
28 * Array of entities on which commenting is enabled, keyed by id
29 * @param string $entity_type
30 * The entity type of the passed entities.
31 * @param bool $accurate
32 * (optional) Indicates if results must be completely up to date. If set to
33 * FALSE, a replica database will used if available. Defaults to TRUE.
36 * Array of statistics records.
38 public function read($entities, $entity_type, $accurate = TRUE);
41 * Delete comment statistics records for an entity.
43 * @param \Drupal\Core\Entity\EntityInterface $entity
44 * The entity for which comment statistics should be deleted.
46 public function delete(EntityInterface $entity);
49 * Update or insert comment statistics records after a comment is added.
51 * @param \Drupal\comment\CommentInterface $comment
52 * The comment added or updated.
54 public function update(CommentInterface $comment);
57 * Find the maximum number of comments for the given entity type.
59 * Used to influence search rankings.
61 * @param string $entity_type
62 * The entity type to consider when fetching the maximum comment count for.
65 * The maximum number of comments for and entity of the given type.
67 * @see comment_update_index()
69 public function getMaximumCount($entity_type);
72 * Insert an empty record for the given entity.
74 * @param \Drupal\Core\Entity\FieldableEntityInterface $entity
75 * The created entity for which a statistics record is to be initialized.
76 * @param array $fields
77 * Array of comment field definitions for the given entity.
79 public function create(FieldableEntityInterface $entity, $fields);