1 | <?php namespace Limoncello\Testing; |
||
28 | trait ApplicationWrapperTrait |
||
29 | { |
||
30 | /** Called right before request will be passed through all middleware, controller and back */ |
||
31 | protected static $EVENT_ON_HANDLE_REQUEST = 0; |
||
32 | |||
33 | /** Called when response has passed back all middleware right before sending to client */ |
||
34 | protected static $EVENT_ON_HANDLE_RESPONSE = 1; |
||
35 | |||
36 | /** Called on empty container created (before it's set up) */ |
||
37 | protected static $EVENT_ON_CONTAINER_CREATED = 2; |
||
38 | |||
39 | /** Called right before controller is called */ |
||
40 | protected static $EVENT_ON_CONTAINER_LAST_CONFIGURATOR = 3; |
||
41 | |||
42 | /** |
||
43 | * @var array |
||
44 | */ |
||
45 | private $events = []; |
||
46 | |||
47 | /** |
||
48 | * @var PsrContainerInterface |
||
49 | */ |
||
50 | private $container; |
||
51 | |||
52 | /** |
||
53 | * @param Closure $handler |
||
54 | * |
||
55 | * @return void |
||
56 | */ |
||
57 | 1 | public function addOnHandleRequest(Closure $handler) |
|
61 | |||
62 | /** |
||
63 | * @param Closure $handler |
||
64 | * |
||
65 | * @return void |
||
66 | */ |
||
67 | 1 | public function addOnHandleResponse(Closure $handler) |
|
71 | |||
72 | /** |
||
73 | * @param Closure $handler |
||
74 | * |
||
75 | * @return void |
||
76 | */ |
||
77 | 1 | public function addOnContainerCreated(Closure $handler) |
|
81 | |||
82 | /** |
||
83 | * @param Closure $handler |
||
84 | * |
||
85 | * @return void |
||
86 | */ |
||
87 | 1 | public function addOnContainerLastConfigurator(Closure $handler) |
|
91 | |||
92 | /** |
||
93 | * @param int $eventId |
||
94 | * @param Closure $handler |
||
95 | * |
||
96 | * @return void |
||
97 | */ |
||
98 | 1 | protected function addEventHandler(int $eventId, Closure $handler) |
|
109 | |||
110 | /** |
||
111 | * @param int $eventId |
||
112 | * @param array $arguments |
||
113 | * |
||
114 | * @return void |
||
115 | */ |
||
116 | 1 | protected function dispatchEvent($eventId, array $arguments) |
|
123 | |||
124 | /** |
||
125 | * @return LimoncelloContainerInterface |
||
126 | */ |
||
127 | 1 | protected function createContainerInstance(): LimoncelloContainerInterface |
|
136 | |||
137 | /** |
||
138 | * @param LimoncelloContainerInterface $container |
||
139 | * @param array|null $globalConfigurators |
||
140 | * @param array|null $routeConfigurators |
||
141 | * |
||
142 | * @return void |
||
143 | */ |
||
144 | 1 | protected function configureContainer( |
|
154 | |||
155 | /** |
||
156 | * @param Closure $handler |
||
157 | * @param RequestInterface|null $request |
||
158 | * |
||
159 | * @return ResponseInterface |
||
160 | */ |
||
161 | 1 | protected function handleRequest(Closure $handler, RequestInterface $request = null): ResponseInterface |
|
172 | |||
173 | /** |
||
174 | * @return PsrContainerInterface |
||
175 | */ |
||
176 | 1 | protected function getContainer(): PsrContainerInterface |
|
180 | } |
||
181 |