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