summaryrefslogtreecommitdiff
path: root/app/Formatter/TaskListFormatter.php
blob: 01fbbae0d078a667c9545fd46f7d014ee71baf0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php

namespace Kanboard\Formatter;

use Kanboard\Core\Filter\FormatterInterface;

/**
 * Class TaskListFormatter
 *
 * @package Kanboard\Formatter
 * @author  Frederic Guillot
 */
class TaskListFormatter extends BaseFormatter implements FormatterInterface
{
    /**
     * Apply formatter
     *
     * @access public
     * @return mixed
     */
    public function format()
    {
        $tasks = $this->query->findAll();
        $taskIds = array_column($tasks, 'id');
        $tags = $this->taskTagModel->getTagsByTasks($taskIds);
        array_merge_relation($tasks, $tags, 'tags', 'id');

        return $tasks;
    }
}