Use BoardFormatter to generate the board
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user