1 | <?php |
||
25 | class EventCaller implements EventHandlerInterface |
||
26 | { |
||
27 | /** |
||
28 | * List of handlers |
||
29 | * |
||
30 | * @var EventHandlerInterface[] |
||
31 | */ |
||
32 | private $handlers = []; |
||
33 | |||
34 | /** |
||
35 | * Request executor |
||
36 | * |
||
37 | * @var RequestExecutorInterface |
||
38 | */ |
||
39 | private $executor; |
||
40 | |||
41 | /** |
||
42 | * RequestDescriptor |
||
43 | * |
||
44 | * @var RequestDescriptor |
||
45 | */ |
||
46 | private $currentOperation; |
||
47 | |||
48 | /** |
||
49 | * EventCaller constructor. |
||
50 | * |
||
51 | * @param RequestExecutorInterface $executor Request executor |
||
52 | */ |
||
53 | 204 | public function __construct(RequestExecutorInterface $executor) |
|
57 | |||
58 | /** |
||
59 | * Add given handler to list |
||
60 | * |
||
61 | * @param EventHandlerInterface $handler |
||
62 | * |
||
63 | * @return void |
||
64 | */ |
||
65 | 135 | public function addHandler(EventHandlerInterface $handler) |
|
69 | |||
70 | /** |
||
71 | * Sets CurrentOperation |
||
72 | * |
||
73 | * @param RequestDescriptor $currentOperation New value for CurrentOperation |
||
74 | * |
||
75 | * @return void |
||
76 | */ |
||
77 | 168 | public function setCurrentOperation(RequestDescriptor $currentOperation) |
|
81 | |||
82 | /** |
||
83 | * Clear current operation object |
||
84 | * |
||
85 | * @return void |
||
86 | */ |
||
87 | 168 | public function clearCurrentOperation() |
|
91 | |||
92 | /** {@inheritdoc} */ |
||
93 | 81 | public function invokeEvent( |
|
101 | |||
102 | /** |
||
103 | * Notify handlers about given event |
||
104 | * |
||
105 | * @param RequestDescriptor $requestDescriptor Request descriptor |
||
106 | * @param Event $event Event object |
||
107 | * @param RequestExecutorInterface $executor Request executor |
||
108 | * @param ExecutionContext $context Execution context |
||
109 | * |
||
110 | * @return void |
||
111 | */ |
||
112 | 134 | public function callSocketSubscribers( |
|
128 | |||
129 | /** |
||
130 | * Notify handlers about exception |
||
131 | * |
||
132 | * @param RequestDescriptor $requestDescriptor Socket operation object |
||
133 | * @param SocketException $exception Thrown exception |
||
134 | * @param RequestExecutorInterface $executor Request executor |
||
135 | * @param ExecutionContext $context Execution context |
||
136 | * |
||
137 | * @return void |
||
138 | */ |
||
139 | 58 | public function callExceptionSubscribers( |
|
158 | } |
||
159 |