CommentInterface.php 6.1 KB

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