Associate tags to tasks in BoardFormatter
This commit is contained in:
@@ -13,9 +13,23 @@ use Kanboard\Core\Filter\FormatterInterface;
|
||||
class BoardTaskFormatter extends BaseFormatter implements FormatterInterface
|
||||
{
|
||||
protected $tasks = array();
|
||||
protected $tags = array();
|
||||
protected $columnId = 0;
|
||||
protected $swimlaneId = 0;
|
||||
|
||||
/**
|
||||
* Set tags
|
||||
*
|
||||
* @access public
|
||||
* @param array $tags
|
||||
* @return $this
|
||||
*/
|
||||
public function withTags(array $tags)
|
||||
{
|
||||
$this->tags = $tags;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set tasks
|
||||
*
|
||||
@@ -63,17 +77,19 @@ class BoardTaskFormatter extends BaseFormatter implements FormatterInterface
|
||||
*/
|
||||
public function format()
|
||||
{
|
||||
return array_values(array_filter($this->tasks, array($this, 'filterTasks')));
|
||||
$tasks = array_values(array_filter($this->tasks, array($this, 'filterTasks')));
|
||||
array_merge_relation($tasks, $this->tags, 'tags', 'id');
|
||||
return $tasks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Keep only tasks of the given column and swimlane
|
||||
*
|
||||
* @access public
|
||||
* @access protected
|
||||
* @param array $task
|
||||
* @return bool
|
||||
*/
|
||||
public function filterTasks(array $task)
|
||||
protected function filterTasks(array $task)
|
||||
{
|
||||
return $task['column_id'] == $this->columnId && $task['swimlane_id'] == $this->swimlaneId;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user