Comment

class OC\Comments\Comment
Source:lib/private/Comments/Comment.php#33
Implements:OCP\Comments\IComment

Properties

protected static property OC\Comments\Comment::$data
Source:lib/private/Comments/Comment.php#34

Methods

public OC\Comments\Comment::__construct($data=null)
Comment constructor.
Source:

lib/private/Comments/Comment.php#56

Parameters:
  • $data (array) optional, array with keys according to column names from

the comments database scheme

public OC\Comments\Comment::getId()
returns the ID of the comment
It may return an empty string, if the comment was not stored.
It is expected that the concrete Comment implementation gives an ID
by itself (e.g. after saving).
Source:lib/private/Comments/Comment.php#72
Returns:string
Since:9.0.0
public OC\Comments\Comment::setId($id)
sets the ID of the comment and returns itself
It is only allowed to set the ID only, if the current id is an empty
string (which means it is not stored in a database, storage or whatever
the concrete implementation does), or vice versa. Changing a given ID is
not permitted and must result in an IllegalIDChangeException.
Source:

lib/private/Comments/Comment.php#89

Parameters:
  • $id (string)
Returns:

\OCP\Comments\IComment

Throws:

\OCP\Comments\IllegalIDChangeException

Since:

9.0.0

public OC\Comments\Comment::getParentId()
returns the parent ID of the comment
Source:lib/private/Comments/Comment.php#109
Returns:string
Since:9.0.0
public OC\Comments\Comment::setParentId($parentId)
sets the parent ID and returns itself
Source:

lib/private/Comments/Comment.php#120

Parameters:
  • $parentId (string)
Returns:

\OCP\Comments\IComment

Since:

9.0.0

public OC\Comments\Comment::getTopmostParentId()
returns the topmost parent ID of the comment
Source:lib/private/Comments/Comment.php#134
Returns:string
Since:9.0.0
public OC\Comments\Comment::setTopmostParentId($id)
sets the topmost parent ID and returns itself
Source:

lib/private/Comments/Comment.php#146

Parameters:
  • $id (string)
Returns:

\OCP\Comments\IComment

Since:

9.0.0

public OC\Comments\Comment::getChildrenCount()
returns the number of children
Source:lib/private/Comments/Comment.php#160
Returns:int
Since:9.0.0
public OC\Comments\Comment::setChildrenCount($count)
sets the number of children
Source:

lib/private/Comments/Comment.php#171

Parameters:
  • $count (int)
Returns:

\OCP\Comments\IComment

Since:

9.0.0

public OC\Comments\Comment::getMessage()
returns the message of the comment
Source:lib/private/Comments/Comment.php#185
Returns:string
Since:9.0.0
public OC\Comments\Comment::setMessage($message, $maxLength=self::MAX_MESSAGE_LENGTH)
sets the message of the comment and returns itself
Source:

lib/private/Comments/Comment.php#198

Parameters:
  • $message (string)
  • $maxLength (int)
Returns:

\OCP\Comments\IComment

Throws:

\OCP\Comments\MessageTooLongException

Since:

9.0.0

public OC\Comments\Comment::getMentions()
returns an array containing mentions that are included in the comment
Source:

lib/private/Comments/Comment.php#230

Returns:

array each mention provides a ‘type’ and an ‘id’, see example below

Since:

11.0.0 The return array looks like: [

[

‘type’ => ‘user’, ‘id’ => ‘citizen4’

], [

‘type’ => ‘group’, ‘id’ => ‘media’

], …

]

public OC\Comments\Comment::getVerb()
returns the verb of the comment
Source:lib/private/Comments/Comment.php#257
Returns:string
Since:9.0.0
public OC\Comments\Comment::setVerb($verb)
sets the verb of the comment, e.g. ‘comment’ or ‘like’
Source:

lib/private/Comments/Comment.php#268

Parameters:
  • $verb (string)
Returns:

\OCP\Comments\IComment

Since:

9.0.0

public OC\Comments\Comment::getActorType()
returns the actor type
Source:lib/private/Comments/Comment.php#282
Returns:string
Since:9.0.0
public OC\Comments\Comment::getActorId()
returns the actor ID
Source:lib/private/Comments/Comment.php#292
Returns:string
Since:9.0.0
public OC\Comments\Comment::setActor($actorType, $actorId)
sets (overwrites) the actor type and id
Source:

lib/private/Comments/Comment.php#304

Parameters:
  • $actorType (string) e.g. ‘users’
  • $actorId (string) e.g. ‘zombie234’
Returns:

\OCP\Comments\IComment

Since:

9.0.0

public OC\Comments\Comment::getCreationDateTime()
returns the creation date of the comment.
If not explicitly set, it shall default to the time of initialization.
Source:lib/private/Comments/Comment.php#324
Returns:\DateTime
Since:9.0.0
public OC\Comments\Comment::setCreationDateTime($timestamp)
sets the creation date of the comment and returns itself
Source:

lib/private/Comments/Comment.php#335

Parameters:
  • $timestamp (DateTime)
Returns:

\OCP\Comments\IComment

Since:

9.0.0

public OC\Comments\Comment::getLatestChildDateTime()
returns the DateTime of the most recent child, if set, otherwise null
Source:lib/private/Comments/Comment.php#346
Returns:\DateTime | null
Since:9.0.0
public OC\Comments\Comment::setLatestChildDateTime($dateTime=null)
sets the date of the most recent child
Source:

lib/private/Comments/Comment.php#357

Parameters:
  • $dateTime (DateTime)
Returns:

\OCP\Comments\IComment

Since:

9.0.0

public OC\Comments\Comment::getObjectType()
returns the object type the comment is attached to
Source:lib/private/Comments/Comment.php#368
Returns:string
Since:9.0.0
public OC\Comments\Comment::getObjectId()
returns the object id the comment is attached to
Source:lib/private/Comments/Comment.php#378
Returns:string
Since:9.0.0
public OC\Comments\Comment::setObject($objectType, $objectId)
sets (overwrites) the object of the comment
Source:

lib/private/Comments/Comment.php#390

Parameters:
  • $objectType (string) e.g. ‘files’
  • $objectId (string) e.g. ‘16435’
Returns:

\OCP\Comments\IComment

Since:

9.0.0

public OC\Comments\Comment::getReferenceId()
returns the reference id of the comment
Source:lib/private/Comments/Comment.php#408
Returns:string | null
Since:19.0.0
public OC\Comments\Comment::setReferenceId($referenceId)
sets (overwrites) the reference id of the comment
Source:

lib/private/Comments/Comment.php#419

Parameters:
  • $referenceId (string) e.g. sha256 hash sum
Returns:

\OCP\Comments\IComment

Since:

19.0.0

protected OC\Comments\Comment::fromArray($data)
sets the comment data based on an array with keys as taken from the
database.
Source:

lib/private/Comments/Comment.php#439

Parameters:
  • $data (array)
Returns:

\OCP\Comments\IComment