]> source.dussan.org Git - nextcloud-server.git/commitdiff
Allow to set and get the reference id
authorJoas Schilling <coding@schilljs.com>
Wed, 11 Mar 2020 11:11:01 +0000 (12:11 +0100)
committerJoas Schilling <coding@schilljs.com>
Tue, 31 Mar 2020 08:51:16 +0000 (10:51 +0200)
Signed-off-by: Joas Schilling <coding@schilljs.com>
lib/private/Comments/Comment.php
lib/private/Comments/Manager.php
lib/public/Comments/IComment.php

index 71687c7a60920fe971fd367a662502c898d32748..3b4a523b8848c3aa86d9d84ec6dd88c8f92ad6c2 100644 (file)
@@ -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.
index f1c7224359774ea3ea5bd4145992c1e02afd906b..aad7cad020095ab67d3a28a9d7e5b98174e8c0fe 100644 (file)
@@ -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;
        }
 
index aac68a4036ba10dbf672102f44438bd22b384ce7..b98a015a30e4954898685a77b20d40da0c2019d1 100644 (file)
@@ -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;
+
 }