PresenterSubscriber::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Symnedi\EventDispatcher\Tests\NetteEvent\EventSubscriber;
4
5
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
6
use Symnedi\EventDispatcher\Event\PresenterResponseEvent;
7
use Symnedi\EventDispatcher\NettePresenterEvents;
8
use Symnedi\EventDispatcher\Tests\NetteEvent\EventStateStorage;
9
10
11
final class PresenterSubscriber implements EventSubscriberInterface
12
{
13
14
	/**
15
	 * @var EventStateStorage
16
	 */
17
	private $eventStateStorage;
18
19
20
	public function __construct(EventStateStorage $eventStateStorage)
21
	{
22
		$this->eventStateStorage = $eventStateStorage;
23
	}
24
25
26
	/**
27
	 * {@inheritdoc}
28
	 */
29
	public static function getSubscribedEvents()
30
	{
31
		return [NettePresenterEvents::ON_SHUTDOWN => 'onShutdown'];
32
	}
33
34
35
	public function onShutdown(PresenterResponseEvent $presenterResponseEvent)
36
	{
37
		$this->eventStateStorage->addEventState(NettePresenterEvents::ON_SHUTDOWN, $presenterResponseEvent);
38
	}
39
40
}
41