Allow to set and get the reference id

Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/19890/head
Joas Schilling 5 years ago
parent 720dc4e93d
commit a20e81f0f3
No known key found for this signature in database
GPG Key ID: 7076EA9751AACDDA
  1. 31
      lib/private/Comments/Comment.php
  2. 1
      lib/private/Comments/Manager.php
  3. 17
      lib/public/Comments/IComment.php

@ -42,6 +42,7 @@ class Comment implements IComment {
'actorId' => '',
'objectType' => '',
'objectId' => '',
'referenceId' => null,
'creationDT' => null,
'latestChildDT' => null,
];
@ -395,6 +396,36 @@ class Comment implements IComment {
return $this;
}
/**
* returns the reference id of the comment
*
* @return string|null
* @since 19.0.0
*/
public function getReferenceId(): ?string {
return $this->data['referenceId'];
}
/**
* sets (overwrites) the reference id of the comment
*
* @param string $referenceId e.g. sha256 hash sum
* @return IComment
* @since 19.0.0
*/
public function setReferenceId(?string $referenceId): IComment {
if ($referenceId === null) {
$this->data['referenceId'] = $referenceId;
} else {
$referenceId = trim($referenceId);
if ($referenceId === '') {
throw new \InvalidArgumentException('Non empty string expected.');
}
$this->data['referenceId'] = $referenceId;
}
return $this;
}
/**
* sets the comment data based on an array with keys as taken from the
* database.

@ -96,6 +96,7 @@ class Manager implements ICommentsManager {
$data['latest_child_timestamp'] = new \DateTime($data['latest_child_timestamp']);
}
$data['children_count'] = (int)$data['children_count'];
$data['reference_id'] = $data['reference_id'] ?? null;
return $data;
}

@ -263,4 +263,21 @@ interface IComment {
*/
public function setObject($objectType, $objectId);
/**
* returns the reference id of the comment
*
* @return string|null
* @since 19.0.0
*/
public function getReferenceId(): ?string;
/**
* sets (overwrites) the reference id of the comment
*
* @param string|null $referenceId e.g. sha256 hash sum
* @return IComment
* @since 19.0.0
*/
public function setReferenceId(?string $referenceId): IComment;
}

Loading…
Cancel
Save