|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the Drest package. |
|
4
|
|
|
* |
|
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
6
|
|
|
* file that was distributed with this source code. |
|
7
|
|
|
* |
|
8
|
|
|
* @author Lee Davis |
|
9
|
|
|
* @copyright Copyright (c) Lee Davis <@leedavis81> |
|
10
|
|
|
* @link https://github.com/leedavis81/drest/blob/master/LICENSE |
|
11
|
|
|
* @license http://opensource.org/licenses/MIT The MIT X License (MIT) |
|
12
|
|
|
*/ |
|
13
|
|
|
namespace Drest; |
|
14
|
|
|
|
|
15
|
|
|
trait EventManagerTrait |
|
16
|
|
|
{ |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Event manager object |
|
20
|
|
|
* @var Event\Manager |
|
21
|
|
|
*/ |
|
22
|
|
|
protected $eventManager; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Get the event manager |
|
26
|
|
|
* @return Event\Manager |
|
27
|
|
|
*/ |
|
28
|
31 |
|
public function getEventManager() |
|
29
|
|
|
{ |
|
30
|
31 |
|
return $this->eventManager; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Trigger the pre dispatch event |
|
35
|
|
|
* @param Service $service |
|
36
|
|
|
*/ |
|
37
|
31 |
|
public function triggerPreDispatchEvent(Service $service) |
|
38
|
|
|
{ |
|
39
|
|
|
// trigger preDispatch event |
|
40
|
31 |
|
$this->getEventManager()->dispatchEvent( |
|
41
|
31 |
|
Event\Events::PRE_DISPATCH, |
|
42
|
31 |
|
new Event\PreDispatchArgs($service) |
|
43
|
31 |
|
); |
|
44
|
31 |
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Trigger the post dispatch event |
|
48
|
|
|
* @param Service $service |
|
49
|
|
|
*/ |
|
50
|
31 |
|
public function triggerPostDispatchEvent(Service $service) |
|
51
|
|
|
{ |
|
52
|
|
|
// trigger a postDispatch event |
|
53
|
31 |
|
$this->getEventManager()->dispatchEvent( |
|
54
|
31 |
|
Event\Events::POST_DISPATCH, |
|
55
|
31 |
|
new Event\PostDispatchArgs($service) |
|
56
|
31 |
|
); |
|
57
|
31 |
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Trigger the pre routing event |
|
61
|
|
|
* @param Service $service |
|
62
|
|
|
*/ |
|
63
|
31 |
|
public function triggerPreRoutingEvent(Service $service) |
|
64
|
|
|
{ |
|
65
|
31 |
|
$this->getEventManager()->dispatchEvent( |
|
66
|
31 |
|
Event\Events::PRE_ROUTING, |
|
67
|
31 |
|
new Event\PreRoutingArgs($service) |
|
68
|
31 |
|
); |
|
69
|
31 |
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Trigger the post routing event |
|
73
|
|
|
* @param Service $service |
|
74
|
|
|
*/ |
|
75
|
31 |
|
public function triggerPostRoutingEvent(Service $service) |
|
76
|
|
|
{ |
|
77
|
31 |
|
$this->getEventManager()->dispatchEvent( |
|
78
|
31 |
|
Event\Events::POST_ROUTING, |
|
79
|
31 |
|
new Event\PostRoutingArgs($service) |
|
80
|
31 |
|
); |
|
81
|
31 |
|
} |
|
82
|
|
|
|
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* Trigger the pre service action event |
|
86
|
|
|
* @param Service $service |
|
87
|
|
|
*/ |
|
88
|
25 |
|
public function triggerPreServiceActionEvent(Service $service) |
|
89
|
|
|
{ |
|
90
|
25 |
|
$this->getEventManager()->dispatchEvent( |
|
91
|
25 |
|
Event\Events::PRE_SERVICE_ACTION, |
|
92
|
25 |
|
new Event\PreServiceActionArgs($service) |
|
93
|
25 |
|
); |
|
94
|
25 |
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* Trigger the post service action event |
|
98
|
|
|
* @param Service $service |
|
99
|
|
|
*/ |
|
100
|
25 |
|
public function triggerPostServiceActionEvent(Service $service) |
|
101
|
|
|
{ |
|
102
|
25 |
|
$this->getEventManager()->dispatchEvent( |
|
103
|
25 |
|
Event\Events::POST_SERVICE_ACTION, |
|
104
|
25 |
|
new Event\PostServiceActionArgs($service) |
|
105
|
25 |
|
); |
|
106
|
25 |
|
} |
|
107
|
|
|
|
|
108
|
|
|
} |