From 7b8f24648072da16dd46930b494336105cd45990 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Thu, 3 Aug 2017 21:47:52 +0200 Subject: [PATCH] Add serialization --- Models/KanbanCard.php | 24 ++++++++++++++++++++++-- Theme/Backend/kanban-card-create.tpl.php | 0 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 Theme/Backend/kanban-card-create.tpl.php diff --git a/Models/KanbanCard.php b/Models/KanbanCard.php index bd5105b..cbc6ae2 100644 --- a/Models/KanbanCard.php +++ b/Models/KanbanCard.php @@ -191,9 +191,29 @@ class KanbanCard implements \JsonSerializable public function jsonSerialize() : array { - return []; + return [ + 'title' => $this->name, + 'description' => $this->description, + 'status' => $this->status, + 'type' => $this->type, + 'column' => $this->name, + 'order' => $this->name, + 'ref' => $this->name, + 'createdBy' => $this->name, + 'createdAt' => $this->name, + 'labels' => $this->name, + 'comments' => $this->name, + 'media' => $this->name, + ]; + } + + public static function createFromTask(Task $task) : KanbanCard + { + $card = new self(); + $card->setRef($task->getId()); + + return $card; } - /* todo: create function to create card from task etc... this fills the values here. what happens if task changes? bad idea! */ /* todo: maybe allow ref to be an object and datamapper creates that object? how does the datamapper know what kind of datamapper to use? Just assume it's called ObjectMapper? bad isn't it?! */ } \ No newline at end of file diff --git a/Theme/Backend/kanban-card-create.tpl.php b/Theme/Backend/kanban-card-create.tpl.php new file mode 100644 index 0000000..e69de29