Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 namespace Drupal\comment;
|
Chris@0
|
4
|
Chris@0
|
5 use Drupal\Core\Entity\FieldableEntityInterface;
|
Chris@0
|
6 use Drupal\Core\Entity\EntityInterface;
|
Chris@0
|
7
|
Chris@0
|
8 /**
|
Chris@0
|
9 * Provides an interface for storing and retrieving comment statistics.
|
Chris@0
|
10 */
|
Chris@0
|
11 interface CommentStatisticsInterface {
|
Chris@0
|
12
|
Chris@0
|
13 /**
|
Chris@0
|
14 * Returns an array of ranking information for hook_ranking().
|
Chris@0
|
15 *
|
Chris@0
|
16 * @return array
|
Chris@0
|
17 * Array of ranking information as expected by hook_ranking().
|
Chris@0
|
18 *
|
Chris@0
|
19 * @see hook_ranking()
|
Chris@0
|
20 * @see comment_ranking()
|
Chris@0
|
21 */
|
Chris@0
|
22 public function getRankingInfo();
|
Chris@0
|
23
|
Chris@0
|
24 /**
|
Chris@0
|
25 * Read comment statistics records for an array of entities.
|
Chris@0
|
26 *
|
Chris@0
|
27 * @param \Drupal\Core\Entity\EntityInterface[] $entities
|
Chris@0
|
28 * Array of entities on which commenting is enabled, keyed by id
|
Chris@0
|
29 * @param string $entity_type
|
Chris@0
|
30 * The entity type of the passed entities.
|
Chris@0
|
31 * @param bool $accurate
|
Chris@0
|
32 * (optional) Indicates if results must be completely up to date. If set to
|
Chris@0
|
33 * FALSE, a replica database will used if available. Defaults to TRUE.
|
Chris@0
|
34 *
|
Chris@0
|
35 * @return object[]
|
Chris@0
|
36 * Array of statistics records.
|
Chris@0
|
37 */
|
Chris@0
|
38 public function read($entities, $entity_type, $accurate = TRUE);
|
Chris@0
|
39
|
Chris@0
|
40 /**
|
Chris@0
|
41 * Delete comment statistics records for an entity.
|
Chris@0
|
42 *
|
Chris@0
|
43 * @param \Drupal\Core\Entity\EntityInterface $entity
|
Chris@0
|
44 * The entity for which comment statistics should be deleted.
|
Chris@0
|
45 */
|
Chris@0
|
46 public function delete(EntityInterface $entity);
|
Chris@0
|
47
|
Chris@0
|
48 /**
|
Chris@0
|
49 * Update or insert comment statistics records after a comment is added.
|
Chris@0
|
50 *
|
Chris@0
|
51 * @param \Drupal\comment\CommentInterface $comment
|
Chris@0
|
52 * The comment added or updated.
|
Chris@0
|
53 */
|
Chris@0
|
54 public function update(CommentInterface $comment);
|
Chris@0
|
55
|
Chris@0
|
56 /**
|
Chris@0
|
57 * Find the maximum number of comments for the given entity type.
|
Chris@0
|
58 *
|
Chris@0
|
59 * Used to influence search rankings.
|
Chris@0
|
60 *
|
Chris@0
|
61 * @param string $entity_type
|
Chris@0
|
62 * The entity type to consider when fetching the maximum comment count for.
|
Chris@0
|
63 *
|
Chris@0
|
64 * @return int
|
Chris@0
|
65 * The maximum number of comments for and entity of the given type.
|
Chris@0
|
66 *
|
Chris@0
|
67 * @see comment_update_index()
|
Chris@0
|
68 */
|
Chris@0
|
69 public function getMaximumCount($entity_type);
|
Chris@0
|
70
|
Chris@0
|
71 /**
|
Chris@0
|
72 * Insert an empty record for the given entity.
|
Chris@0
|
73 *
|
Chris@0
|
74 * @param \Drupal\Core\Entity\FieldableEntityInterface $entity
|
Chris@0
|
75 * The created entity for which a statistics record is to be initialized.
|
Chris@0
|
76 * @param array $fields
|
Chris@0
|
77 * Array of comment field definitions for the given entity.
|
Chris@0
|
78 */
|
Chris@0
|
79 public function create(FieldableEntityInterface $entity, $fields);
|
Chris@0
|
80
|
Chris@0
|
81 }
|