Completed
Push — master ( b15ea3...332a47 )
by WEBEWEB
01:49
created

NotificationEventListener::onNotify()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/**
4
 * This file is part of the bootstrap-bundle package.
5
 *
6
 * (c) 2018 WEBEWEB
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Bundle\BootstrapBundle\EventListener;
13
14
use WBW\Bundle\BootstrapBundle\Event\NotificationEvent;
15
16
/**
17
 * Notification event listener.
18
 *
19
 * @author webeweb <https://github.com/webeweb/>
20
 * @package WBW\Bundle\BootstrapBundle\EventListener
21
 */
22
class NotificationEventListener {
23
24
    /**
25
     * Service name.
26
     *
27
     * @var string
28
     */
29
    const SERVICE_NAME = "webeweb.bundle.bootstrapbundle.eventlistener.notification";
30
31
    /**
32
     * Kernel event listener.
33
     *
34
     * @var KernelEventListener
35
     */
36
    private $kernelEventListener;
37
38
    /**
39
     * Constructor.
40
     *
41
     * @param KernelEventListener $kernelEventListener The kernel event listener.
42
     */
43
    public function __construct(KernelEventListener $kernelEventListener) {
44
        $this->kernelEventListener = $kernelEventListener;
45
    }
46
47
    /**
48
     * On notify.
49
     *
50
     * @param NotificationEvent $event The notification event.
51
     * @return void
52
     */
53
    public function onNotify(NotificationEvent $event) {
54
        $this->kernelEventListener->getRequest()->getSession()->getFlashBag()->add($event->getType(), $event->getNotification());
55
    }
56
57
}
58