1 | <?php |
||
15 | class ExceptionEvent extends Event |
||
16 | { |
||
17 | /** |
||
18 | * @var RequestInterface |
||
19 | */ |
||
20 | protected $request; |
||
21 | |||
22 | /** |
||
23 | * @var ResponseInterface |
||
24 | */ |
||
25 | protected $response; |
||
26 | |||
27 | /** |
||
28 | * @var \Throwable |
||
29 | */ |
||
30 | protected $exception; |
||
31 | |||
32 | /** |
||
33 | * If the exception will be resolved to a response (through setResponse()), |
||
34 | * response-event will be fired until explicitly disabled by this property. |
||
35 | * |
||
36 | * @var bool |
||
37 | */ |
||
38 | protected $responseEventEnabled = true; |
||
39 | |||
40 | /** |
||
41 | * ExceptionEvent constructor. |
||
42 | * |
||
43 | * @param RequestInterface $request |
||
44 | * @param \Throwable $exception |
||
45 | */ |
||
46 | 5 | public function __construct(RequestInterface $request, \Throwable $exception) |
|
51 | |||
52 | /** |
||
53 | * Get request |
||
54 | * |
||
55 | * @return RequestInterface |
||
56 | */ |
||
57 | 2 | public function getRequest(): RequestInterface |
|
61 | |||
62 | /** |
||
63 | * Get exception |
||
64 | * |
||
65 | * @return \Throwable |
||
66 | */ |
||
67 | 2 | public function getException(): \Throwable |
|
71 | |||
72 | /** |
||
73 | * Set response |
||
74 | * |
||
75 | * @param ResponseInterface $response |
||
76 | */ |
||
77 | 2 | public function setResponse(ResponseInterface $response) |
|
81 | |||
82 | /** |
||
83 | * Has a response set by previous listeners ? |
||
84 | * |
||
85 | * @return bool |
||
86 | */ |
||
87 | 3 | public function hasResponse(): bool |
|
91 | |||
92 | /** |
||
93 | * Get response |
||
94 | * |
||
95 | * @return ResponseInterface |
||
96 | * @throws \OutOfBoundsException |
||
97 | */ |
||
98 | 2 | public function getResponse(): ResponseInterface |
|
106 | |||
107 | /** |
||
108 | * Disable dispatching of response-event. |
||
109 | * Enabled by default. |
||
110 | */ |
||
111 | 1 | public function disableResponseEvent() |
|
115 | |||
116 | /** |
||
117 | * Enable dispatching of response-event. |
||
118 | * Can be useful to reenable after has been disabled by another event-listener. |
||
119 | */ |
||
120 | public function enableResponseEvent() |
||
124 | |||
125 | /** |
||
126 | * Is response event enabled to dispatch in the case if the exception |
||
127 | * will be resolved to a response (through setResponse()) ? |
||
128 | * |
||
129 | * @return bool |
||
130 | */ |
||
131 | 2 | public function isResponseEventEnabled(): bool |
|
135 | } |