diff options
| author | Teamjungla{CODE} <junglacode@gmail.com> | 2016-08-20 13:47:12 -0500 |
|---|---|---|
| committer | Teamjungla{CODE} <junglacode@gmail.com> | 2016-08-20 13:47:12 -0500 |
| commit | fe8e9cdcfe3afc1475c7e7f4392d2b2cc601a12b (patch) | |
| tree | 001403874e9e3716de7c6d51a9f536e9b3c3be5e /app/Formatter/BoardFormatter.php | |
| parent | b1e795fc5b45369f7b9b565b1e106d2673361977 (diff) | |
| parent | 98efcf21e355ed6ac3827058b99df86ca67c75bb (diff) | |
Merge branch 'stable' of https://github.com/kanboard/kanboard
Diffstat (limited to 'app/Formatter/BoardFormatter.php')
| -rw-r--r-- | app/Formatter/BoardFormatter.php | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/app/Formatter/BoardFormatter.php b/app/Formatter/BoardFormatter.php index dbc7cf21..350dde6c 100644 --- a/app/Formatter/BoardFormatter.php +++ b/app/Formatter/BoardFormatter.php @@ -28,7 +28,7 @@ class BoardFormatter extends BaseFormatter implements FormatterInterface * @param integer $projectId * @return $this */ - public function setProjectId($projectId) + public function withProjectId($projectId) { $this->projectId = $projectId; return $this; @@ -42,15 +42,25 @@ class BoardFormatter extends BaseFormatter implements FormatterInterface */ public function format() { + $swimlanes = $this->swimlaneModel->getSwimlanes($this->projectId); + $columns = $this->columnModel->getAll($this->projectId); $tasks = $this->query ->eq(TaskModel::TABLE.'.project_id', $this->projectId) ->asc(TaskModel::TABLE.'.position') ->findAll(); - return $this->boardModel->getBoard($this->projectId, function ($project_id, $column_id, $swimlane_id) use ($tasks) { - return array_filter($tasks, function (array $task) use ($column_id, $swimlane_id) { - return $task['column_id'] == $column_id && $task['swimlane_id'] == $swimlane_id; - }); - }); + $task_ids = array_column($tasks, 'id'); + $tags = $this->taskTagModel->getTagsByTasks($task_ids); + + if (empty($swimlanes) || empty($columns)) { + return array(); + } + + return BoardSwimlaneFormatter::getInstance($this->container) + ->withSwimlanes($swimlanes) + ->withColumns($columns) + ->withTasks($tasks) + ->withTags($tags) + ->format(); } } |
