3 namespace Drupal\comment;
5 use Drupal\Core\Entity\ContentEntityInterface;
6 use Drupal\Core\Entity\EntityPublishedInterface;
7 use Drupal\user\EntityOwnerInterface;
8 use Drupal\Core\Entity\EntityChangedInterface;
11 * Provides an interface defining a comment entity.
13 interface CommentInterface extends ContentEntityInterface, EntityChangedInterface, EntityOwnerInterface, EntityPublishedInterface {
16 * Comment is awaiting approval.
18 const NOT_PUBLISHED = 0;
21 * Comment is published.
26 * Anonymous posters cannot enter their contact information.
28 const ANONYMOUS_MAYNOT_CONTACT = 0;
31 * Anonymous posters may leave their contact information.
33 const ANONYMOUS_MAY_CONTACT = 1;
36 * Anonymous posters are required to leave their contact information.
38 const ANONYMOUS_MUST_CONTACT = 2;
41 * Determines if this comment is a reply to another comment.
44 * TRUE if the comment has a parent comment otherwise FALSE.
46 public function hasParentComment();
49 * Returns the parent comment entity if this is a reply to a comment.
51 * @return \Drupal\comment\CommentInterface|null
52 * A comment entity of the parent comment or NULL if there is no parent.
54 public function getParentComment();
57 * Returns the entity to which the comment is attached.
59 * @return \Drupal\Core\Entity\FieldableEntityInterface
60 * The entity on which the comment is attached.
62 public function getCommentedEntity();
65 * Returns the ID of the entity to which the comment is attached.
68 * The ID of the entity to which the comment is attached.
70 public function getCommentedEntityId();
73 * Returns the type of the entity to which the comment is attached.
78 public function getCommentedEntityTypeId();
81 * Sets the field ID for which this comment is attached.
83 * @param string $field_name
84 * The field name through which the comment was added.
87 * The class instance that this method is called on.
89 public function setFieldName($field_name);
92 * Returns the name of the field the comment is attached to.
95 * The name of the field the comment is attached to.
97 public function getFieldName();
100 * Returns the subject of the comment.
103 * The subject of the comment.
105 public function getSubject();
108 * Sets the subject of the comment.
110 * @param string $subject
111 * The subject of the comment.
114 * The class instance that this method is called on.
116 public function setSubject($subject);
119 * Returns the comment author's name.
121 * For anonymous authors, this is the value as typed in the comment form.
124 * The name of the comment author.
126 public function getAuthorName();
129 * Sets the name of the author of the comment.
131 * @param string $name
132 * A string containing the name of the author.
135 * The class instance that this method is called on.
137 public function setAuthorName($name);
140 * Returns the comment author's email address.
142 * For anonymous authors, this is the value as typed in the comment form.
145 * The email address of the author of the comment.
147 public function getAuthorEmail();
150 * Returns the comment author's home page address.
152 * For anonymous authors, this is the value as typed in the comment form.
155 * The homepage address of the author of the comment.
157 public function getHomepage();
160 * Sets the comment author's home page address.
162 * For anonymous authors, this is the value as typed in the comment form.
164 * @param string $homepage
165 * The homepage address of the author of the comment.
168 * The class instance that this method is called on.
170 public function setHomepage($homepage);
173 * Returns the comment author's hostname.
176 * The hostname of the author of the comment.
178 public function getHostname();
181 * Sets the hostname of the author of the comment.
183 * @param string $hostname
184 * The hostname of the author of the comment.
187 * The class instance that this method is called on.
189 public function setHostname($hostname);
192 * Returns the time that the comment was created.
195 * The timestamp of when the comment was created.
197 public function getCreatedTime();
200 * Sets the creation date of the comment.
202 * @param int $created
203 * The timestamp of when the comment was created.
206 * The class instance that this method is called on.
208 public function setCreatedTime($created);
211 * Returns the comment's status.
214 * One of CommentInterface::PUBLISHED or CommentInterface::NOT_PUBLISHED
216 * @deprecated in Drupal 8.3.0, will be removed before Drupal 9.0.0. Use
217 * \Drupal\Core\Entity\EntityPublishedInterface::isPublished() instead.
219 public function getStatus();
222 * Returns the alphadecimal representation of the comment's place in a thread.
225 * The alphadecimal representation of the comment's place in a thread.
227 public function getThread();
230 * Sets the alphadecimal representation of the comment's place in a thread.
232 * @param string $thread
233 * The alphadecimal representation of the comment's place in a thread.
236 * The class instance that this method is called on.
238 public function setThread($thread);
241 * Returns the permalink URL for this comment.
243 * @return \Drupal\Core\Url
245 public function permalink();
248 * Get the comment type id for this comment.
251 * The id of the comment type.
253 public function getTypeId();