Use BoardFormatter to generate the board

This commit is contained in:
Frederic Guillot
2016-06-24 08:50:57 -04:00
parent d560f84b37
commit 9e278a9370
16 changed files with 667 additions and 217 deletions

View File

@@ -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();
}
}