summaryrefslogtreecommitdiff
path: root/app/Formatter/TaskAutoCompleteFormatter.php
blob: 4f1c4c69d329c38fa1212717d7c63b18d65e233a (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
31
32
33
<?php

namespace Kanboard\Formatter;

use Kanboard\Core\Filter\FormatterInterface;
use Kanboard\Model\TaskModel;

/**
 * Task AutoComplete Formatter
 *
 * @package formatter
 * @author  Frederic Guillot
 */
class TaskAutoCompleteFormatter extends BaseFormatter implements FormatterInterface
{
    /**
     * Apply formatter
     *
     * @access public
     * @return array
     */
    public function format()
    {
        $tasks = $this->query->columns(TaskModel::TABLE.'.id', TaskModel::TABLE.'.title')->findAll();

        foreach ($tasks as &$task) {
            $task['value'] = $task['title'];
            $task['label'] = '#'.$task['id'].' - '.$task['title'];
        }

        return $tasks;
    }
}