1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of Symnedi. |
5
|
|
|
* Copyright (c) 2014 Tomas Votruba (http://tomasvotruba.cz) |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace Symnedi\EventDispatcher\DI; |
9
|
|
|
|
10
|
|
|
use Nette\Application\Application; |
11
|
|
|
use Nette\Application\UI\Presenter; |
12
|
|
|
use Symnedi\EventDispatcher\Contract\DI\NetteEventListFactoryInterface; |
13
|
|
|
use Symnedi\EventDispatcher\Event\ApplicationEvent; |
14
|
|
|
use Symnedi\EventDispatcher\Event\ApplicationExceptionEvent; |
15
|
|
|
use Symnedi\EventDispatcher\Event\ApplicationPresenterEvent; |
16
|
|
|
use Symnedi\EventDispatcher\Event\ApplicationRequestEvent; |
17
|
|
|
use Symnedi\EventDispatcher\Event\ApplicationResponseEvent; |
18
|
|
|
use Symnedi\EventDispatcher\Event\PresenterResponseEvent; |
19
|
|
|
use Symnedi\EventDispatcher\NetteApplicationEvents; |
20
|
|
|
use Symnedi\EventDispatcher\NettePresenterEvents; |
21
|
|
|
|
22
|
|
|
|
23
|
|
|
final class NetteEventListFactory implements NetteEventListFactoryInterface |
24
|
|
|
{ |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* {@inheritdoc} |
28
|
|
|
*/ |
29
|
3 |
|
public function create() |
30
|
|
|
{ |
31
|
3 |
|
$list = []; |
32
|
3 |
|
$list = $this->addApplicationEventItems($list); |
33
|
3 |
|
$list = $this->addPresenterEventItems($list); |
34
|
3 |
|
return $list; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @param NetteEventItem[] $list |
40
|
|
|
* @return NetteEventItem[] |
41
|
|
|
*/ |
42
|
3 |
|
private function addApplicationEventItems(array $list) |
43
|
|
|
{ |
44
|
3 |
|
$list[] = new NetteEventItem( |
45
|
3 |
|
Application::class, 'onRequest', ApplicationRequestEvent::class, NetteApplicationEvents::ON_REQUEST |
46
|
3 |
|
); |
47
|
3 |
|
$list[] = new NetteEventItem( |
48
|
3 |
|
Application::class, 'onStartup', ApplicationEvent::class, NetteApplicationEvents::ON_STARTUP |
49
|
3 |
|
); |
50
|
3 |
|
$list[] = new NetteEventItem( |
51
|
3 |
|
Application::class, 'onPresenter', ApplicationPresenterEvent::class, NetteApplicationEvents::ON_PRESENTER |
52
|
3 |
|
); |
53
|
3 |
|
$list[] = new NetteEventItem( |
54
|
3 |
|
Application::class, 'onResponse', ApplicationResponseEvent::class, NetteApplicationEvents::ON_RESPONSE |
55
|
3 |
|
); |
56
|
3 |
|
$list[] = new NetteEventItem( |
57
|
3 |
|
Application::class, 'onError', ApplicationExceptionEvent::class, NetteApplicationEvents::ON_ERROR |
58
|
3 |
|
); |
59
|
3 |
|
$list[] = new NetteEventItem( |
60
|
3 |
|
Application::class, 'onShutdown', ApplicationExceptionEvent::class, NetteApplicationEvents::ON_SHUTDOWN |
61
|
3 |
|
); |
62
|
3 |
|
return $list; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @param NetteEventItem[] $list |
68
|
|
|
* @return NetteEventItem[] |
69
|
|
|
*/ |
70
|
3 |
|
private function addPresenterEventItems(array $list) |
71
|
|
|
{ |
72
|
3 |
|
$list[] = new NetteEventItem( |
73
|
3 |
|
Presenter::class, 'onShutdown', PresenterResponseEvent::class, NettePresenterEvents::ON_SHUTDOWN |
74
|
3 |
|
); |
75
|
3 |
|
return $list; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
} |
79
|
|
|
|