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