diff options
Diffstat (limited to 'app/Formatter')
-rw-r--r-- | app/Formatter/BoardFormatter.php | 2 | ||||
-rw-r--r-- | app/Formatter/SubtaskListFormatter.php | 2 | ||||
-rw-r--r-- | app/Formatter/TaskListFormatter.php | 4 | ||||
-rw-r--r-- | app/Formatter/TaskListSubtaskFormatter.php | 29 |
4 files changed, 33 insertions, 4 deletions
diff --git a/app/Formatter/BoardFormatter.php b/app/Formatter/BoardFormatter.php index 59a8fb18..a43790b0 100644 --- a/app/Formatter/BoardFormatter.php +++ b/app/Formatter/BoardFormatter.php @@ -58,7 +58,7 @@ class BoardFormatter extends BaseFormatter implements FormatterInterface ->findAll(); $task_ids = array_column($tasks, 'id'); - $tags = $this->taskTagModel->getTagsByTasks($task_ids); + $tags = $this->taskTagModel->getTagsByTaskIds($task_ids); return $this->boardSwimlaneFormatter ->withSwimlanes($swimlanes) diff --git a/app/Formatter/SubtaskListFormatter.php b/app/Formatter/SubtaskListFormatter.php index 5b20111d..8af5b1f5 100644 --- a/app/Formatter/SubtaskListFormatter.php +++ b/app/Formatter/SubtaskListFormatter.php @@ -16,7 +16,7 @@ class SubtaskListFormatter extends BaseFormatter implements FormatterInterface * Apply formatter * * @access public - * @return mixed + * @return array */ public function format() { diff --git a/app/Formatter/TaskListFormatter.php b/app/Formatter/TaskListFormatter.php index 01fbbae0..2f83469d 100644 --- a/app/Formatter/TaskListFormatter.php +++ b/app/Formatter/TaskListFormatter.php @@ -16,13 +16,13 @@ class TaskListFormatter extends BaseFormatter implements FormatterInterface * Apply formatter * * @access public - * @return mixed + * @return array */ public function format() { $tasks = $this->query->findAll(); $taskIds = array_column($tasks, 'id'); - $tags = $this->taskTagModel->getTagsByTasks($taskIds); + $tags = $this->taskTagModel->getTagsByTaskIds($taskIds); array_merge_relation($tasks, $tags, 'tags', 'id'); return $tasks; diff --git a/app/Formatter/TaskListSubtaskFormatter.php b/app/Formatter/TaskListSubtaskFormatter.php new file mode 100644 index 00000000..4f889674 --- /dev/null +++ b/app/Formatter/TaskListSubtaskFormatter.php @@ -0,0 +1,29 @@ +<?php + +namespace Kanboard\Formatter; + +/** + * Class TaskListSubtaskFormatter + * + * @package Kanboard\Formatter + * @author Frederic Guillot + */ +class TaskListSubtaskFormatter extends TaskListFormatter +{ + /** + * Apply formatter + * + * @access public + * @return array + */ + public function format() + { + $tasks = parent::format(); + $taskIds = array_column($tasks, 'id'); + $subtasks = $this->subtaskModel->getAllByTaskIds($taskIds); + $subtasks = array_column_index($subtasks, 'task_id'); + array_merge_relation($tasks, $subtasks, 'subtasks', 'id'); + + return $tasks; + } +} |