1 | <?php |
||
29 | class DispatcherMiddleware implements MiddlewareInterface |
||
30 | { |
||
31 | /** |
||
32 | * @var ControllerDispatchInflectorInterface |
||
33 | */ |
||
34 | private $inflector; |
||
35 | |||
36 | /** |
||
37 | * @var ControllerInvokerInterface |
||
38 | */ |
||
39 | private $invoker; |
||
40 | |||
41 | /** |
||
42 | * @var ContextCreator |
||
43 | */ |
||
44 | private $contextCreator; |
||
45 | |||
46 | /** |
||
47 | * DispatcherMiddleware constructor. |
||
48 | * @param ControllerDispatchInflectorInterface $inflector |
||
49 | * @param ControllerInvokerInterface $invoker |
||
50 | * @param ContextCreator $contextCreator |
||
51 | */ |
||
52 | public function __construct( |
||
61 | |||
62 | /** |
||
63 | * Process an incoming server request and return a response, optionally delegating |
||
64 | * response creation to a handler. |
||
65 | * |
||
66 | * @param ServerRequestInterface $request |
||
67 | * @param RequestHandlerInterface $handler |
||
68 | * |
||
69 | * @return ResponseInterface |
||
70 | * |
||
71 | * @throws BadHttpStackConfigurationException When the need route is missing from the request |
||
72 | * @throws MissingResponseException When context has disabled the rendering and has no response object to return |
||
73 | */ |
||
74 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler) |
||
90 | |||
91 | /** |
||
92 | * Get route attribute from request |
||
93 | * |
||
94 | * @param ServerRequestInterface $request |
||
95 | * |
||
96 | * @return Route |
||
97 | * |
||
98 | * @throws BadHttpStackConfigurationException When the need route is missing from the request |
||
99 | */ |
||
100 | private function route(ServerRequestInterface $request) |
||
112 | |||
113 | /** |
||
114 | * Merges any existing view data in the request with the provided one |
||
115 | * |
||
116 | * @param ServerRequestInterface $request |
||
117 | * @param array $data |
||
118 | * |
||
119 | * @return array |
||
120 | */ |
||
121 | private function merge(ServerRequestInterface $request, array $data) |
||
126 | |||
127 | /** |
||
128 | * Verify and return the response from the context |
||
129 | * |
||
130 | * @param ControllerContextInterface $context |
||
131 | * |
||
132 | * @return ResponseInterface |
||
133 | * |
||
134 | * @throws MissingResponseException When context has no response object to return |
||
135 | */ |
||
136 | private function responseFrom(ControllerContextInterface $context) |
||
149 | } |
||
150 |