Pull merge.
[yaffs-website] / web / core / modules / comment / src / CommentInterface.php
1 <?php
2
3 namespace Drupal\comment;
4
5 use Drupal\Core\Entity\ContentEntityInterface;
6 use Drupal\Core\Entity\EntityPublishedInterface;
7 use Drupal\user\EntityOwnerInterface;
8 use Drupal\Core\Entity\EntityChangedInterface;
9
10 /**
11  * Provides an interface defining a comment entity.
12  */
13 interface CommentInterface extends ContentEntityInterface, EntityChangedInterface, EntityOwnerInterface, EntityPublishedInterface {
14
15   /**
16    * Comment is awaiting approval.
17    */
18   const NOT_PUBLISHED = 0;
19
20   /**
21    * Comment is published.
22    */
23   const PUBLISHED = 1;
24
25   /**
26    * Anonymous posters cannot enter their contact information.
27    */
28   const ANONYMOUS_MAYNOT_CONTACT = 0;
29
30   /**
31    * Anonymous posters may leave their contact information.
32    */
33   const ANONYMOUS_MAY_CONTACT = 1;
34
35   /**
36    * Anonymous posters are required to leave their contact information.
37    */
38   const ANONYMOUS_MUST_CONTACT = 2;
39
40   /**
41    * Determines if this comment is a reply to another comment.
42    *
43    * @return bool
44    *   TRUE if the comment has a parent comment otherwise FALSE.
45    */
46   public function hasParentComment();
47
48   /**
49    * Returns the parent comment entity if this is a reply to a comment.
50    *
51    * @return \Drupal\comment\CommentInterface|null
52    *   A comment entity of the parent comment or NULL if there is no parent.
53    */
54   public function getParentComment();
55
56   /**
57    * Returns the entity to which the comment is attached.
58    *
59    * @return \Drupal\Core\Entity\FieldableEntityInterface|null
60    *   The entity on which the comment is attached or NULL if the comment is an
61    *   orphan.
62    */
63   public function getCommentedEntity();
64
65   /**
66    * Returns the ID of the entity to which the comment is attached.
67    *
68    * @return int
69    *   The ID of the entity to which the comment is attached.
70    */
71   public function getCommentedEntityId();
72
73   /**
74    * Returns the type of the entity to which the comment is attached.
75    *
76    * @return string
77    *   An entity type.
78    */
79   public function getCommentedEntityTypeId();
80
81   /**
82    * Sets the field ID for which this comment is attached.
83    *
84    * @param string $field_name
85    *   The field name through which the comment was added.
86    *
87    * @return $this
88    *   The class instance that this method is called on.
89    */
90   public function setFieldName($field_name);
91
92   /**
93    * Returns the name of the field the comment is attached to.
94    *
95    * @return string
96    *   The name of the field the comment is attached to.
97    */
98   public function getFieldName();
99
100   /**
101    * Returns the subject of the comment.
102    *
103    * @return string
104    *   The subject of the comment.
105    */
106   public function getSubject();
107
108   /**
109    * Sets the subject of the comment.
110    *
111    * @param string $subject
112    *   The subject of the comment.
113    *
114    * @return $this
115    *   The class instance that this method is called on.
116    */
117   public function setSubject($subject);
118
119   /**
120    * Returns the comment author's name.
121    *
122    * For anonymous authors, this is the value as typed in the comment form.
123    *
124    * @return string
125    *   The name of the comment author.
126    */
127   public function getAuthorName();
128
129   /**
130    * Sets the name of the author of the comment.
131    *
132    * @param string $name
133    *   A string containing the name of the author.
134    *
135    * @return $this
136    *   The class instance that this method is called on.
137    */
138   public function setAuthorName($name);
139
140   /**
141    * Returns the comment author's email address.
142    *
143    * For anonymous authors, this is the value as typed in the comment form.
144    *
145    * @return string
146    *   The email address of the author of the comment.
147    */
148   public function getAuthorEmail();
149
150   /**
151    * Returns the comment author's home page address.
152    *
153    * For anonymous authors, this is the value as typed in the comment form.
154    *
155    * @return string
156    *   The homepage address of the author of the comment.
157    */
158   public function getHomepage();
159
160   /**
161    * Sets the comment author's home page address.
162    *
163    * For anonymous authors, this is the value as typed in the comment form.
164    *
165    * @param string $homepage
166    *   The homepage address of the author of the comment.
167    *
168    * @return $this
169    *   The class instance that this method is called on.
170    */
171   public function setHomepage($homepage);
172
173   /**
174    * Returns the comment author's hostname.
175    *
176    * @return string
177    *   The hostname of the author of the comment.
178    */
179   public function getHostname();
180
181   /**
182    * Sets the hostname of the author of the comment.
183    *
184    * @param string $hostname
185    *   The hostname of the author of the comment.
186    *
187    * @return $this
188    *   The class instance that this method is called on.
189    */
190   public function setHostname($hostname);
191
192   /**
193    * Returns the time that the comment was created.
194    *
195    * @return int
196    *   The timestamp of when the comment was created.
197    */
198   public function getCreatedTime();
199
200   /**
201    * Sets the creation date of the comment.
202    *
203    * @param int $created
204    *   The timestamp of when the comment was created.
205    *
206    * @return $this
207    *   The class instance that this method is called on.
208    */
209   public function setCreatedTime($created);
210
211   /**
212    * Returns the comment's status.
213    *
214    * @return int
215    *   One of CommentInterface::PUBLISHED or CommentInterface::NOT_PUBLISHED
216    *
217    * @deprecated in Drupal 8.3.0, will be removed before Drupal 9.0.0. Use
218    *   \Drupal\Core\Entity\EntityPublishedInterface::isPublished() instead.
219    */
220   public function getStatus();
221
222   /**
223    * Returns the alphadecimal representation of the comment's place in a thread.
224    *
225    * @return string
226    *   The alphadecimal representation of the comment's place in a thread.
227    */
228   public function getThread();
229
230   /**
231    * Sets the alphadecimal representation of the comment's place in a thread.
232    *
233    * @param string $thread
234    *   The alphadecimal representation of the comment's place in a thread.
235    *
236    * @return $this
237    *   The class instance that this method is called on.
238    */
239   public function setThread($thread);
240
241   /**
242    * Returns the permalink URL for this comment.
243    *
244    * @return \Drupal\Core\Url
245    */
246   public function permalink();
247
248   /**
249    * Get the comment type id for this comment.
250    *
251    * @return string
252    *   The id of the comment type.
253    */
254   public function getTypeId();
255
256 }