Skip to content
Snippets Groups Projects
Unverified Commit a20e81f0 authored by Joas Schilling's avatar Joas Schilling
Browse files

Allow to set and get the reference id

parent 720dc4e9
No related branches found
No related tags found
No related merge requests found
...@@ -42,6 +42,7 @@ class Comment implements IComment { ...@@ -42,6 +42,7 @@ class Comment implements IComment {
'actorId' => '', 'actorId' => '',
'objectType' => '', 'objectType' => '',
'objectId' => '', 'objectId' => '',
'referenceId' => null,
'creationDT' => null, 'creationDT' => null,
'latestChildDT' => null, 'latestChildDT' => null,
]; ];
...@@ -395,6 +396,36 @@ class Comment implements IComment { ...@@ -395,6 +396,36 @@ class Comment implements IComment {
return $this; 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 * sets the comment data based on an array with keys as taken from the
* database. * database.
......
...@@ -96,6 +96,7 @@ class Manager implements ICommentsManager { ...@@ -96,6 +96,7 @@ class Manager implements ICommentsManager {
$data['latest_child_timestamp'] = new \DateTime($data['latest_child_timestamp']); $data['latest_child_timestamp'] = new \DateTime($data['latest_child_timestamp']);
} }
$data['children_count'] = (int)$data['children_count']; $data['children_count'] = (int)$data['children_count'];
$data['reference_id'] = $data['reference_id'] ?? null;
return $data; return $data;
} }
......
...@@ -263,4 +263,21 @@ interface IComment { ...@@ -263,4 +263,21 @@ interface IComment {
*/ */
public function setObject($objectType, $objectId); 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;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment