mirror of
https://github.com/nextcloud/server.git
synced 2026-06-09 08:44:07 -04:00
Allow to set and get the reference id
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
720dc4e93d
commit
a20e81f0f3
3 changed files with 49 additions and 0 deletions
|
|
@ -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…
Reference in a new issue