summaryrefslogtreecommitdiff
path: root/app/Formatter/SubtaskListFormatter.php
blob: 5b20111dd0633d45a789f82966bd0d0b24bef56e (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 mixed
     */
    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;
    }
}