CommentInterface.php 6.05 KB
Newer Older
1 2 3 4
<?php

/**
 * @file
5
 * Contains \Drupal\comment\CommentInterface.
6 7 8 9 10
 */

namespace Drupal\comment;

use Drupal\Core\Entity\ContentEntityInterface;
11
use Drupal\user\EntityOwnerInterface;
12
use Drupal\Core\Entity\EntityChangedInterface;
13 14 15 16

/**
 * Provides an interface defining a comment entity.
 */
17
interface CommentInterface extends ContentEntityInterface, EntityChangedInterface, EntityOwnerInterface {
18

19 20 21 22 23 24 25 26 27 28
  /**
   * Comment is awaiting approval.
   */
  const NOT_PUBLISHED = 0;

  /**
   * Comment is published.
   */
  const PUBLISHED = 1;

29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
  /**
   * Determines if this comment is a reply to another comment.
   *
   * @return bool
   *   TRUE if the comment has a parent comment otherwise FALSE.
   */
  public function hasParentComment();

  /**
   * Returns the parent comment entity if this is a reply to a comment.
   *
   * @return \Drupal\comment\CommentInterface|NULL
   *   A comment entity of the parent comment or NULL if there is no parent.
   */
  public function getParentComment();

  /**
   * Returns the entity to which the comment is attached.
   *
   * @return \Drupal\Core\Entity\EntityInterface
   *   The entity on which the comment is attached.
   */
  public function getCommentedEntity();

  /**
   * Returns the ID of the entity to which the comment is attached.
   *
   * @return int
   *   The ID of the entity to which the comment is attached.
   */
  public function getCommentedEntityId();

  /**
   * Returns the type of the entity to which the comment is attached.
   *
   * @return string
   *   An entity type.
   */
  public function getCommentedEntityTypeId();

  /**
   * Sets the field ID for which this comment is attached.
   *
72 73
   * @param string $field_name
   *   The field name through which the comment was added.
74 75 76 77
   *
   * @return $this
   *   The class instance that this method is called on.
   */
78
  public function setFieldName($field_name);
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128

  /**
   * Returns the name of the field the comment is attached to.
   *
   * @return string
   *   The name of the field the comment is attached to.
   */
  public function getFieldName();

  /**
   * Returns the subject of the comment.
   *
   * @return string
   *   The subject of the comment.
   */
  public function getSubject();

  /**
   * Sets the subject of the comment.
   *
   * @param string $subject
   *   The subject of the comment.
   *
   * @return $this
   *   The class instance that this method is called on.
   */
  public function setSubject($subject);

  /**
   * Returns the comment author's name.
   *
   * For anonymous authors, this is the value as typed in the comment form.
   *
   * @return string
   *   The name of the comment author.
   */
  public function getAuthorName();

  /**
   * Sets the name of the author of the comment.
   *
   * @param string $name
   *   A string containing the name of the author.
   *
   * @return $this
   *   The class instance that this method is called on.
   */
  public function setAuthorName($name);

  /**
129
   * Returns the comment author's email address.
130 131 132 133
   *
   * For anonymous authors, this is the value as typed in the comment form.
   *
   * @return string
134
   *   The email address of the author of the comment.
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244
   */
  public function getAuthorEmail();

  /**
   * Returns the comment author's home page address.
   *
   * For anonymous authors, this is the value as typed in the comment form.
   *
   * @return string
   *   The homepage address of the author of the comment.
   */
  public function getHomepage();

  /**
   * Sets the comment author's home page address.
   *
   * For anonymous authors, this is the value as typed in the comment form.
   *
   * @param string $homepage
   *   The homepage address of the author of the comment.
   *
   * @return $this
   *   The class instance that this method is called on.
   */
  public function setHomepage($homepage);

  /**
   * Returns the comment author's hostname.
   *
   * @return string
   *   The hostname of the author of the comment.
   */
  public function getHostname();

  /**
   * Sets the hostname of the author of the comment.
   *
   * @param string $hostname
   *   The hostname of the author of the comment.
   *
   * @return $this
   *   The class instance that this method is called on.
   */
  public function setHostname($hostname);

  /**
   * Returns the time that the comment was created.
   *
   * @return int
   *   The timestamp of when the comment was created.
   */
  public function getCreatedTime();

  /**
   * Sets the creation date of the comment.
   *
   * @param int $created
   *   The timestamp of when the comment was created.
   *
   * @return $this
   *   The class instance that this method is called on.
   */
  public function setCreatedTime($created);

  /**
   * Returns the timestamp of when the comment was updated.
   *
   * @return int
   *   The timestamp of when the comment was updated.
   */
  public function getChangedTime();

  /**
   * Checks if the comment is published.
   *
   * @return bool
   *   TRUE if the comment is published.
   */
  public function isPublished();

  /**
   * Sets the published status of the comment entity.
   *
   * @param bool $status
   *   Set to TRUE to publish the comment, FALSE to unpublish.
   *
   * @return \Drupal\comment\CommentInterface
   *   The class instance that this method is called on.
   */
  public function setPublished($status);

  /**
   * Returns the alphadecimal representation of the comment's place in a thread.
   *
   * @return string
   *   The alphadecimal representation of the comment's place in a thread.
   */
  public function getThread();

  /**
   * Sets the alphadecimal representation of the comment's place in a thread.
   *
   * @param string $thread
   *   The alphadecimal representation of the comment's place in a thread.
   *
   * @return $this
   *   The class instance that this method is called on.
   */
  public function setThread($thread);

245 246 247
  /**
   * Returns the permalink URL for this comment.
   *
248
   * @return \Drupal\Core\Url
249 250
   */
  public function permalink();
251

252 253 254 255 256 257 258 259
  /**
   * Get the comment type id for this comment.
   *
   * @return string
   *   The id of the comment type.
   */
  public function getTypeId();

260
}