|
<?php |
|
|
|
namespace Kanboard\Formatter; |
|
|
|
use Kanboard\Core\Filter\FormatterInterface; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BoardTaskFormatter extends BaseFormatter implements FormatterInterface |
|
{ |
|
protected $tasks = array(); |
|
protected $tags = array(); |
|
protected $columnId = 0; |
|
protected $swimlaneId = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function withTags(array $tags) |
|
{ |
|
$this->tags = $tags; |
|
return $this; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function withTasks(array $tasks) |
|
{ |
|
$this->tasks = $tasks; |
|
return $this; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function withColumnId($columnId) |
|
{ |
|
$this->columnId = $columnId; |
|
return $this; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function withSwimlaneId($swimlaneId) |
|
{ |
|
$this->swimlaneId = $swimlaneId; |
|
return $this; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function format() |
|
{ |
|
$tasks = array_values(array_filter($this->tasks, array($this, 'filterTasks'))); |
|
array_merge_relation($tasks, $this->tags, 'tags', 'id'); |
|
|
|
foreach ($tasks as &$task) { |
|
$task['is_draggable'] = $this->helper->projectRole->isDraggable($task); |
|
} |
|
|
|
return $tasks; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected function filterTasks(array $task) |
|
{ |
|
return $task['column_id'] == $this->columnId && $task['swimlane_id'] == $this->swimlaneId; |
|
} |
|
} |
|
|