Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 namespace Drupal\comment;
|
Chris@0
|
4
|
Chris@0
|
5 use Drupal\Core\Entity\EntityInterface;
|
Chris@0
|
6
|
Chris@0
|
7 /**
|
Chris@0
|
8 * Comment manager contains common functions to manage comment fields.
|
Chris@0
|
9 */
|
Chris@0
|
10 interface CommentManagerInterface {
|
Chris@0
|
11
|
Chris@0
|
12 /**
|
Chris@0
|
13 * Comments are displayed in a flat list - expanded.
|
Chris@0
|
14 */
|
Chris@0
|
15 const COMMENT_MODE_FLAT = 0;
|
Chris@0
|
16
|
Chris@0
|
17 /**
|
Chris@0
|
18 * Comments are displayed as a threaded list - expanded.
|
Chris@0
|
19 */
|
Chris@0
|
20 const COMMENT_MODE_THREADED = 1;
|
Chris@0
|
21
|
Chris@0
|
22 /**
|
Chris@0
|
23 * Utility function to return an array of comment fields.
|
Chris@0
|
24 *
|
Chris@0
|
25 * @param string $entity_type_id
|
Chris@0
|
26 * The content entity type to which the comment fields are attached.
|
Chris@0
|
27 *
|
Chris@0
|
28 * @return array
|
Chris@0
|
29 * An array of comment field map definitions, keyed by field name. Each
|
Chris@0
|
30 * value is an array with two entries:
|
Chris@0
|
31 * - type: The field type.
|
Chris@0
|
32 * - bundles: The bundles in which the field appears, as an array with entity
|
Chris@0
|
33 * types as keys and the array of bundle names as values.
|
Chris@0
|
34 *
|
Chris@0
|
35 * @see \Drupal\Core\Entity\EntityManagerInterface::getFieldMap()
|
Chris@0
|
36 */
|
Chris@0
|
37 public function getFields($entity_type_id);
|
Chris@0
|
38
|
Chris@0
|
39 /**
|
Chris@0
|
40 * Creates a comment_body field.
|
Chris@0
|
41 *
|
Chris@0
|
42 * @param string $comment_type
|
Chris@0
|
43 * The comment bundle.
|
Chris@0
|
44 */
|
Chris@0
|
45 public function addBodyField($comment_type);
|
Chris@0
|
46
|
Chris@0
|
47 /**
|
Chris@0
|
48 * Provides a message if posting comments is forbidden.
|
Chris@0
|
49 *
|
Chris@0
|
50 * If authenticated users can post comments, a message is returned that
|
Chris@0
|
51 * prompts the anonymous user to log in (or register, if applicable) that
|
Chris@0
|
52 * redirects to entity comment form. Otherwise, no message is returned.
|
Chris@0
|
53 *
|
Chris@0
|
54 * @param \Drupal\Core\Entity\EntityInterface $entity
|
Chris@0
|
55 * The entity to which comments are attached to.
|
Chris@0
|
56 * @param string $field_name
|
Chris@0
|
57 * The field name on the entity to which comments are attached to.
|
Chris@0
|
58 *
|
Chris@0
|
59 * @return string
|
Chris@0
|
60 * HTML for a "you can't post comments" notice.
|
Chris@0
|
61 */
|
Chris@0
|
62 public function forbiddenMessage(EntityInterface $entity, $field_name);
|
Chris@0
|
63
|
Chris@0
|
64 /**
|
Chris@0
|
65 * Returns the number of new comments available on a given entity for a user.
|
Chris@0
|
66 *
|
Chris@0
|
67 * @param \Drupal\Core\Entity\EntityInterface $entity
|
Chris@0
|
68 * The entity to which the comments are attached to.
|
Chris@0
|
69 * @param string $field_name
|
Chris@0
|
70 * (optional) The field_name to count comments for. Defaults to any field.
|
Chris@0
|
71 * @param int $timestamp
|
Chris@0
|
72 * (optional) Time to count from. Defaults to time of last user access the
|
Chris@0
|
73 * entity.
|
Chris@0
|
74 *
|
Chris@0
|
75 * @return int|false
|
Chris@0
|
76 * The number of new comments or FALSE if the user is not authenticated.
|
Chris@0
|
77 */
|
Chris@0
|
78 public function getCountNewComments(EntityInterface $entity, $field_name = NULL, $timestamp = 0);
|
Chris@0
|
79
|
Chris@0
|
80 }
|