1 | <?php |
||
18 | class DispatcherBootstrap implements BootstrapInterface |
||
19 | { |
||
20 | private $env = []; |
||
21 | |||
22 | /** |
||
23 | * @var ViewModel |
||
24 | */ |
||
25 | private $viewModel; |
||
26 | |||
27 | public function __construct() |
||
31 | |||
32 | public function boot(array $env) |
||
33 | { |
||
34 | $this->env = $env; |
||
35 | |||
36 | RequestMatcher::setRequest($this->getServerRequest()); |
||
37 | RequestMatcher::setRouterMap($this->getRouterMap()); |
||
38 | |||
39 | $dispatcher = $this->getDispatcher(); |
||
40 | $viewRenderer = $this->getViewRenderer(); |
||
41 | |||
42 | $controllerResult = $this->getControllerResult($viewRenderer, $dispatcher->dispatch()); |
||
43 | |||
44 | echo $viewRenderer->renderView($controllerResult); |
||
45 | } |
||
46 | |||
47 | private function getControllerResult(ViewRenderer $viewRenderer, $controllerResult) |
||
57 | |||
58 | private function getViewPrefix() |
||
69 | |||
70 | private function getDispatcher() |
||
80 | |||
81 | private function getViewRenderer() |
||
91 | |||
92 | private function getParameterMap() |
||
98 | |||
99 | private function getServerRequest() |
||
100 | { |
||
101 | $request = $this->env['dispatcher']['request']; |
||
102 | |||
103 | $stripedUri = new Uri( |
||
104 | $this->stripAppUrlPrefix($request->getUri()->getPath()) |
||
105 | ); |
||
106 | |||
107 | return $request->withUri($stripedUri); |
||
108 | } |
||
109 | |||
110 | private function stripAppUrlPrefix($url) |
||
120 | |||
121 | private function getRouterMap() |
||
125 | } |
||
126 |