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|null
60 * The entity on which the comment is attached or NULL if the comment is an
63 public function getCommentedEntity();
66 * Returns the ID of the entity to which the comment is attached.
69 * The ID of the entity to which the comment is attached.
71 public function getCommentedEntityId();
74 * Returns the type of the entity to which the comment is attached.
79 public function getCommentedEntityTypeId();
82 * Sets the field ID for which this comment is attached.
84 * @param string $field_name
85 * The field name through which the comment was added.
88 * The class instance that this method is called on.
90 public function setFieldName($field_name);
93 * Returns the name of the field the comment is attached to.
96 * The name of the field the comment is attached to.
98 public function getFieldName();
101 * Returns the subject of the comment.
104 * The subject of the comment.
106 public function getSubject();
109 * Sets the subject of the comment.
111 * @param string $subject
112 * The subject of the comment.
115 * The class instance that this method is called on.
117 public function setSubject($subject);
120 * Returns the comment author's name.
122 * For anonymous authors, this is the value as typed in the comment form.
125 * The name of the comment author.
127 public function getAuthorName();
130 * Sets the name of the author of the comment.
132 * @param string $name
133 * A string containing the name of the author.
136 * The class instance that this method is called on.
138 public function setAuthorName($name);
141 * Returns the comment author's email address.
143 * For anonymous authors, this is the value as typed in the comment form.
146 * The email address of the author of the comment.
148 public function getAuthorEmail();
151 * Returns the comment author's home page address.
153 * For anonymous authors, this is the value as typed in the comment form.
156 * The homepage address of the author of the comment.
158 public function getHomepage();
161 * Sets the comment author's home page address.
163 * For anonymous authors, this is the value as typed in the comment form.
165 * @param string $homepage
166 * The homepage address of the author of the comment.
169 * The class instance that this method is called on.
171 public function setHomepage($homepage);
174 * Returns the comment author's hostname.
177 * The hostname of the author of the comment.
179 public function getHostname();
182 * Sets the hostname of the author of the comment.
184 * @param string $hostname
185 * The hostname of the author of the comment.
188 * The class instance that this method is called on.
190 public function setHostname($hostname);
193 * Returns the time that the comment was created.
196 * The timestamp of when the comment was created.
198 public function getCreatedTime();
201 * Sets the creation date of the comment.
203 * @param int $created
204 * The timestamp of when the comment was created.
207 * The class instance that this method is called on.
209 public function setCreatedTime($created);
212 * Returns the comment's status.
215 * One of CommentInterface::PUBLISHED or CommentInterface::NOT_PUBLISHED
217 * @deprecated in Drupal 8.3.0, will be removed before Drupal 9.0.0. Use
218 * \Drupal\Core\Entity\EntityPublishedInterface::isPublished() instead.
220 public function getStatus();
223 * Returns the alphadecimal representation of the comment's place in a thread.
226 * The alphadecimal representation of the comment's place in a thread.
228 public function getThread();
231 * Sets the alphadecimal representation of the comment's place in a thread.
233 * @param string $thread
234 * The alphadecimal representation of the comment's place in a thread.
237 * The class instance that this method is called on.
239 public function setThread($thread);
242 * Returns the permalink URL for this comment.
244 * @return \Drupal\Core\Url
246 public function permalink();
249 * Get the comment type id for this comment.
252 * The id of the comment type.
254 public function getTypeId();