summaryrefslogtreecommitdiff
path: root/app/Formatter/BoardFormatter.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Formatter/BoardFormatter.php')
-rw-r--r--app/Formatter/BoardFormatter.php19
1 files changed, 13 insertions, 6 deletions
diff --git a/app/Formatter/BoardFormatter.php b/app/Formatter/BoardFormatter.php
index dbc7cf21..562a97bc 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,22 @@ 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;
- });
- });
+ if (empty($swimlanes) || empty($columns)) {
+ return array();
+ }
+
+ return BoardSwimlaneFormatter::getInstance($this->container)
+ ->withSwimlanes($swimlanes)
+ ->withColumns($columns)
+ ->withTasks($tasks)
+ ->format();
}
}