summaryrefslogtreecommitdiff
path: root/app/Helper/ICalHelper.php
blob: dc399bf8be52746df5cee341b06150187677d05d (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
35
36
37
38
<?php

namespace Kanboard\Helper;

use Kanboard\Core\Base;
use Kanboard\Core\Filter\QueryBuilder;
use Kanboard\Filter\TaskDueDateRangeFilter;
use Kanboard\Formatter\TaskICalFormatter;
use Eluceo\iCal\Component\Calendar as iCalendar;

/**
 * ICal Helper
 *
 * @package helper
 * @author  Frederic Guillot
 */
class ICalHelper extends Base
{
    /**
     * Get formatted calendar task due events
     *
     * @access public
     * @param  QueryBuilder  $queryBuilder
     * @param  iCalendar     $calendar
     * @param  string        $start
     * @param  string        $end
     */
    public function addTaskDateDueEvents(QueryBuilder $queryBuilder, iCalendar $calendar, $start, $end)
    {
        $queryBuilder->withFilter(new TaskDueDateRangeFilter(array($start, $end)));

        $formatter = new TaskICalFormatter($this->container);
        $formatter->setColumns('date_due');
        $formatter->setCalendar($calendar);
        $formatter->withQuery($queryBuilder->getQuery());
        $formatter->addFullDayEvents();
    }
}