diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-06-24 10:05:45 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-06-24 10:05:45 -0400 |
commit | 700b4e8f0265e4eabd7a7c0eb6a06088d50554fe (patch) | |
tree | e38c011894e6f53b59557ad9a86fed8ad6bf6049 /app/Formatter/BoardTaskFormatter.php | |
parent | 9e278a9370e3b651a4a545c0c0c0c256088ed187 (diff) |
Associate tags to tasks in BoardFormatter
Diffstat (limited to 'app/Formatter/BoardTaskFormatter.php')
-rw-r--r-- | app/Formatter/BoardTaskFormatter.php | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/app/Formatter/BoardTaskFormatter.php b/app/Formatter/BoardTaskFormatter.php index d9500710..3bf171b1 100644 --- a/app/Formatter/BoardTaskFormatter.php +++ b/app/Formatter/BoardTaskFormatter.php @@ -13,10 +13,24 @@ 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 * * @access public @@ -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; } |