summaryrefslogtreecommitdiff
path: root/app/Subscriber/BootstrapSubscriber.php
blob: 7d12e9ae138bf3835dc28652b2fda858d938920e (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
39
40
41
42
<?php

namespace Kanboard\Subscriber;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class BootstrapSubscriber extends BaseSubscriber implements EventSubscriberInterface
{
    public static function getSubscribedEvents()
    {
        return array(
            'app.bootstrap' => 'execute',
        );
    }

    public function execute()
    {
        $this->logger->debug('Subscriber executed: '.__METHOD__);
        $this->languageModel->loadCurrentLanguage();
        $this->timezoneModel->setCurrentTimezone();
        $this->actionManager->attachEvents();

        if ($this->userSession->isLogged()) {
            $this->sessionStorage->hasSubtaskInProgress = $this->subtaskModel->hasSubtaskInProgress($this->userSession->getId());
        }
    }

    public function __destruct()
    {
        if (DEBUG) {
            foreach ($this->db->getLogMessages() as $message) {
                $this->logger->debug('SQL: ' . $message);
            }

            $this->logger->debug('APP: nb_queries={nb}', array('nb' => $this->db->getStatementHandler()->getNbQueries()));
            $this->logger->debug('APP: rendering_time={time}', array('time' => microtime(true) - $this->request->getStartTime()));
            $this->logger->debug('APP: memory_usage='.$this->helper->text->bytes(memory_get_usage()));
            $this->logger->debug('APP: uri='.$this->request->getUri());
            $this->logger->debug('###############################################');
        }
    }
}