diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-06-24 08:50:57 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-06-24 08:50:57 -0400 |
commit | 9e278a9370e3b651a4a545c0c0c0c256088ed187 (patch) | |
tree | 2738835d2410d183a02f29cf80f96215371cfd11 /app/Formatter/BoardTaskFormatter.php | |
parent | d560f84b374fa1b3345dc582eddd6bb7b9138674 (diff) |
Use BoardFormatter to generate the board
Diffstat (limited to 'app/Formatter/BoardTaskFormatter.php')
-rw-r--r-- | app/Formatter/BoardTaskFormatter.php | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/app/Formatter/BoardTaskFormatter.php b/app/Formatter/BoardTaskFormatter.php new file mode 100644 index 00000000..d9500710 --- /dev/null +++ b/app/Formatter/BoardTaskFormatter.php @@ -0,0 +1,80 @@ +<?php + +namespace Kanboard\Formatter; + +use Kanboard\Core\Filter\FormatterInterface; + +/** + * Board Task Formatter + * + * @package formatter + * @author Frederic Guillot + */ +class BoardTaskFormatter extends BaseFormatter implements FormatterInterface +{ + protected $tasks = array(); + protected $columnId = 0; + protected $swimlaneId = 0; + + /** + * Set tasks + * + * @access public + * @param array $tasks + * @return $this + */ + public function withTasks(array $tasks) + { + $this->tasks = $tasks; + return $this; + } + + /** + * Set columnId + * + * @access public + * @param integer $columnId + * @return $this + */ + public function withColumnId($columnId) + { + $this->columnId = $columnId; + return $this; + } + + /** + * Set swimlaneId + * + * @access public + * @param integer $swimlaneId + * @return $this + */ + public function withSwimlaneId($swimlaneId) + { + $this->swimlaneId = $swimlaneId; + return $this; + } + + /** + * Apply formatter + * + * @access public + * @return array + */ + public function format() + { + return array_values(array_filter($this->tasks, array($this, 'filterTasks'))); + } + + /** + * Keep only tasks of the given column and swimlane + * + * @access public + * @param array $task + * @return bool + */ + public function filterTasks(array $task) + { + return $task['column_id'] == $this->columnId && $task['swimlane_id'] == $this->swimlaneId; + } +} |