summaryrefslogtreecommitdiff
path: root/app/Subscriber/ProjectDailySummarySubscriber.php
blob: b70eaf71e896032e43a5a537c544d945d2e7598b (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\Subscriber;

use Kanboard\Event\TaskEvent;
use Kanboard\Model\Task;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class ProjectDailySummarySubscriber extends BaseSubscriber implements EventSubscriberInterface
{
    public static function getSubscribedEvents()
    {
        return array(
            Task::EVENT_CREATE_UPDATE => 'execute',
            Task::EVENT_CLOSE => 'execute',
            Task::EVENT_OPEN => 'execute',
            Task::EVENT_MOVE_COLUMN => 'execute',
            Task::EVENT_MOVE_SWIMLANE => 'execute',
        );
    }

    public function execute(TaskEvent $event)
    {
        if (isset($event['project_id']) && !$this->isExecuted()) {
            $this->logger->debug('Subscriber executed: '.__CLASS__.'::'.__METHOD__);
            $this->projectDailyColumnStats->updateTotals($event['project_id'], date('Y-m-d'));
            $this->projectDailyStats->updateTotals($event['project_id'], date('Y-m-d'));
        }
    }
}