summaryrefslogtreecommitdiff
path: root/app/Formatter/SubtaskListFormatter.php
blob: 8af5b1f559d933745f15c6fa6030b87660bcd675 (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
34
<?php

namespace Kanboard\Formatter;

use Kanboard\Core\Filter\FormatterInterface;

/**
 * Class SubtaskListFormatter
 *
 * @package Kanboard\Formatter
 * @author  Frederic Guillot
 */
class SubtaskListFormatter extends BaseFormatter implements FormatterInterface
{
    /**
     * Apply formatter
     *
     * @access public
     * @return array
     */
    public function format()
    {
        $status = $this->subtaskModel->getStatusList();
        $subtasks = $this->query->findAll();

        foreach ($subtasks as &$subtask) {
            $subtask['status_name'] = $status[$subtask['status']];
            $subtask['timer_start_date'] = isset($subtask['timer_start_date']) ? $subtask['timer_start_date'] : 0;
            $subtask['is_timer_started'] = ! empty($subtask['timer_start_date']);
        }

        return $subtasks;
    }
}