IComment.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. * @author Roeland Jago Douma <roeland@famdouma.nl>
  7. * @author Thomas Müller <thomas.mueller@tmit.eu>
  8. *
  9. * @license AGPL-3.0
  10. *
  11. * This code is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License, version 3,
  13. * as published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License, version 3,
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>
  22. *
  23. */
  24. namespace OCP\Comments;
  25. /**
  26. * Interface IComment
  27. *
  28. * This class represents a comment
  29. *
  30. * @package OCP\Comments
  31. * @since 9.0.0
  32. */
  33. interface IComment {
  34. const MAX_MESSAGE_LENGTH = 1000;
  35. /**
  36. * returns the ID of the comment
  37. *
  38. * It may return an empty string, if the comment was not stored.
  39. * It is expected that the concrete Comment implementation gives an ID
  40. * by itself (e.g. after saving).
  41. *
  42. * @return string
  43. * @since 9.0.0
  44. */
  45. public function getId();
  46. /**
  47. * sets the ID of the comment and returns itself
  48. *
  49. * It is only allowed to set the ID only, if the current id is an empty
  50. * string (which means it is not stored in a database, storage or whatever
  51. * the concrete implementation does), or vice versa. Changing a given ID is
  52. * not permitted and must result in an IllegalIDChangeException.
  53. *
  54. * @param string $id
  55. * @return IComment
  56. * @throws IllegalIDChangeException
  57. * @since 9.0.0
  58. */
  59. public function setId($id);
  60. /**
  61. * returns the parent ID of the comment
  62. *
  63. * @return string
  64. * @since 9.0.0
  65. */
  66. public function getParentId();
  67. /**
  68. * sets the parent ID and returns itself
  69. * @param string $parentId
  70. * @return IComment
  71. * @since 9.0.0
  72. */
  73. public function setParentId($parentId);
  74. /**
  75. * returns the topmost parent ID of the comment
  76. *
  77. * @return string
  78. * @since 9.0.0
  79. */
  80. public function getTopmostParentId();
  81. /**
  82. * sets the topmost parent ID and returns itself
  83. *
  84. * @param string $id
  85. * @return IComment
  86. * @since 9.0.0
  87. */
  88. public function setTopmostParentId($id);
  89. /**
  90. * returns the number of children
  91. *
  92. * @return int
  93. * @since 9.0.0
  94. */
  95. public function getChildrenCount();
  96. /**
  97. * sets the number of children
  98. *
  99. * @param int $count
  100. * @return IComment
  101. * @since 9.0.0
  102. */
  103. public function setChildrenCount($count);
  104. /**
  105. * returns the message of the comment
  106. *
  107. * @return string
  108. * @since 9.0.0
  109. */
  110. public function getMessage();
  111. /**
  112. * sets the message of the comment and returns itself
  113. *
  114. * When the given message length exceeds MAX_MESSAGE_LENGTH an
  115. * MessageTooLongException shall be thrown.
  116. *
  117. * @param string $message
  118. * @return IComment
  119. * @throws MessageTooLongException
  120. * @since 9.0.0
  121. */
  122. public function setMessage($message);
  123. /**
  124. * returns an array containing mentions that are included in the comment
  125. *
  126. * @return array each mention provides a 'type' and an 'id', see example below
  127. * @since 11.0.0
  128. *
  129. * The return array looks like:
  130. * [
  131. * [
  132. * 'type' => 'user',
  133. * 'id' => 'citizen4'
  134. * ],
  135. * [
  136. * 'type' => 'group',
  137. * 'id' => 'media'
  138. * ],
  139. * …
  140. * ]
  141. *
  142. */
  143. public function getMentions();
  144. /**
  145. * returns the verb of the comment
  146. *
  147. * @return string
  148. * @since 9.0.0
  149. */
  150. public function getVerb();
  151. /**
  152. * sets the verb of the comment, e.g. 'comment' or 'like'
  153. *
  154. * @param string $verb
  155. * @return IComment
  156. * @since 9.0.0
  157. */
  158. public function setVerb($verb);
  159. /**
  160. * returns the actor type
  161. *
  162. * @return string
  163. * @since 9.0.0
  164. */
  165. public function getActorType();
  166. /**
  167. * returns the actor ID
  168. *
  169. * @return string
  170. * @since 9.0.0
  171. */
  172. public function getActorId();
  173. /**
  174. * sets (overwrites) the actor type and id
  175. *
  176. * @param string $actorType e.g. 'users'
  177. * @param string $actorId e.g. 'zombie234'
  178. * @return IComment
  179. * @since 9.0.0
  180. */
  181. public function setActor($actorType, $actorId);
  182. /**
  183. * returns the creation date of the comment.
  184. *
  185. * If not explicitly set, it shall default to the time of initialization.
  186. *
  187. * @return \DateTime
  188. * @since 9.0.0
  189. */
  190. public function getCreationDateTime();
  191. /**
  192. * sets the creation date of the comment and returns itself
  193. *
  194. * @param \DateTime $dateTime
  195. * @return IComment
  196. * @since 9.0.0
  197. */
  198. public function setCreationDateTime(\DateTime $dateTime);
  199. /**
  200. * returns the date of the most recent child
  201. *
  202. * @return \DateTime
  203. * @since 9.0.0
  204. */
  205. public function getLatestChildDateTime();
  206. /**
  207. * sets the date of the most recent child
  208. *
  209. * @param \DateTime $dateTime
  210. * @return IComment
  211. * @since 9.0.0
  212. */
  213. public function setLatestChildDateTime(\DateTime $dateTime);
  214. /**
  215. * returns the object type the comment is attached to
  216. *
  217. * @return string
  218. * @since 9.0.0
  219. */
  220. public function getObjectType();
  221. /**
  222. * returns the object id the comment is attached to
  223. *
  224. * @return string
  225. * @since 9.0.0
  226. */
  227. public function getObjectId();
  228. /**
  229. * sets (overwrites) the object of the comment
  230. *
  231. * @param string $objectType e.g. 'files'
  232. * @param string $objectId e.g. '16435'
  233. * @return IComment
  234. * @since 9.0.0
  235. */
  236. public function setObject($objectType, $objectId);
  237. }