From: Christopher Ng Date: Mon, 31 Jul 2023 19:10:50 +0000 (-0700) Subject: enh: implement JsonSerializable X-Git-Tag: v28.0.0beta1~601^2~29 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=774e3e6d4b9af4a6b329247561f6f85ce354f58d;p=nextcloud-server.git enh: implement JsonSerializable Signed-off-by: Christopher Ng --- diff --git a/apps/files_reminders/lib/Model/RichReminder.php b/apps/files_reminders/lib/Model/RichReminder.php index 21b42d9c2e7..76c3d8dd22b 100644 --- a/apps/files_reminders/lib/Model/RichReminder.php +++ b/apps/files_reminders/lib/Model/RichReminder.php @@ -26,12 +26,14 @@ declare(strict_types=1); namespace OCA\FilesReminders\Model; +use DateTimeInterface; +use JsonSerializable; use OCA\FilesReminders\Db\Reminder; use OCA\FilesReminders\Exception\NodeNotFoundException; use OCP\Files\IRootFolder; use OCP\Files\Node; -class RichReminder extends Reminder { +class RichReminder extends Reminder implements JsonSerializable { public function __construct( private Reminder $reminder, private IRootFolder $root, @@ -59,4 +61,14 @@ class RichReminder extends Reminder { public function __call(string $methodName, array $args) { return $this->reminder->__call($methodName, $args); } + + public function jsonSerialize(): array { + return [ + 'userId' => $this->getUserId(), + 'fileId' => $this->getFileId(), + 'remindAt' => $this->getRemindAt()->format(DateTimeInterface::ATOM), // ISO 8601 + 'createdAt' => $this->getCreatedAt()->format(DateTimeInterface::ATOM), // ISO 8601 + 'notified' => $this->getNotified(), + ]; + } }