CommentInterface.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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
  49. * The entity on which the comment is attached.
  50. */
  51. public function getCommentedEntity();
  52. /**
  53. * Returns the ID of the entity to which the comment is attached.
  54. *
  55. * @return int
  56. * The ID of the entity to which the comment is attached.
  57. */
  58. public function getCommentedEntityId();
  59. /**
  60. * Returns the type of the entity to which the comment is attached.
  61. *
  62. * @return string
  63. * An entity type.
  64. */
  65. public function getCommentedEntityTypeId();
  66. /**
  67. * Sets the field ID for which this comment is attached.
  68. *
  69. * @param string $field_name
  70. * The field name through which the comment was added.
  71. *
  72. * @return $this
  73. * The class instance that this method is called on.
  74. */
  75. public function setFieldName($field_name);
  76. /**
  77. * Returns the name of the field the comment is attached to.
  78. *
  79. * @return string
  80. * The name of the field the comment is attached to.
  81. */
  82. public function getFieldName();
  83. /**
  84. * Returns the subject of the comment.
  85. *
  86. * @return string
  87. * The subject of the comment.
  88. */
  89. public function getSubject();
  90. /**
  91. * Sets the subject of the comment.
  92. *
  93. * @param string $subject
  94. * The subject of the comment.
  95. *
  96. * @return $this
  97. * The class instance that this method is called on.
  98. */
  99. public function setSubject($subject);
  100. /**
  101. * Returns the comment author's name.
  102. *
  103. * For anonymous authors, this is the value as typed in the comment form.
  104. *
  105. * @return string
  106. * The name of the comment author.
  107. */
  108. public function getAuthorName();
  109. /**
  110. * Sets the name of the author of the comment.
  111. *
  112. * @param string $name
  113. * A string containing the name of the author.
  114. *
  115. * @return $this
  116. * The class instance that this method is called on.
  117. */
  118. public function setAuthorName($name);
  119. /**
  120. * Returns the comment author's email address.
  121. *
  122. * For anonymous authors, this is the value as typed in the comment form.
  123. *
  124. * @return string
  125. * The email address of the author of the comment.
  126. */
  127. public function getAuthorEmail();
  128. /**
  129. * Returns the comment author's home page address.
  130. *
  131. * For anonymous authors, this is the value as typed in the comment form.
  132. *
  133. * @return string
  134. * The homepage address of the author of the comment.
  135. */
  136. public function getHomepage();
  137. /**
  138. * Sets the comment author's home page address.
  139. *
  140. * For anonymous authors, this is the value as typed in the comment form.
  141. *
  142. * @param string $homepage
  143. * The homepage address of the author of the comment.
  144. *
  145. * @return $this
  146. * The class instance that this method is called on.
  147. */
  148. public function setHomepage($homepage);
  149. /**
  150. * Returns the comment author's hostname.
  151. *
  152. * @return string
  153. * The hostname of the author of the comment.
  154. */
  155. public function getHostname();
  156. /**
  157. * Sets the hostname of the author of the comment.
  158. *
  159. * @param string $hostname
  160. * The hostname of the author of the comment.
  161. *
  162. * @return $this
  163. * The class instance that this method is called on.
  164. */
  165. public function setHostname($hostname);
  166. /**
  167. * Returns the time that the comment was created.
  168. *
  169. * @return int
  170. * The timestamp of when the comment was created.
  171. */
  172. public function getCreatedTime();
  173. /**
  174. * Sets the creation date of the comment.
  175. *
  176. * @param int $created
  177. * The timestamp of when the comment was created.
  178. *
  179. * @return $this
  180. * The class instance that this method is called on.
  181. */
  182. public function setCreatedTime($created);
  183. /**
  184. * Returns the comment's status.
  185. *
  186. * @return int
  187. * One of CommentInterface::PUBLISHED or CommentInterface::NOT_PUBLISHED
  188. *
  189. * @deprecated in Drupal 8.3.0, will be removed before Drupal 9.0.0. Use
  190. * \Drupal\Core\Entity\EntityPublishedInterface::isPublished() instead.
  191. */
  192. public function getStatus();
  193. /**
  194. * Returns the alphadecimal representation of the comment's place in a thread.
  195. *
  196. * @return string
  197. * The alphadecimal representation of the comment's place in a thread.
  198. */
  199. public function getThread();
  200. /**
  201. * Sets the alphadecimal representation of the comment's place in a thread.
  202. *
  203. * @param string $thread
  204. * The alphadecimal representation of the comment's place in a thread.
  205. *
  206. * @return $this
  207. * The class instance that this method is called on.
  208. */
  209. public function setThread($thread);
  210. /**
  211. * Returns the permalink URL for this comment.
  212. *
  213. * @return \Drupal\Core\Url
  214. */
  215. public function permalink();
  216. /**
  217. * Get the comment type id for this comment.
  218. *
  219. * @return string
  220. * The id of the comment type.
  221. */
  222. public function getTypeId();
  223. }