@@ -47,11 +47,12 @@ |
||
47 | 47 | */ |
48 | 48 | public function call() |
49 | 49 | { |
50 | - if ($this->response->getStatusCode() == 202) |
|
51 | - $this->setContentType($this->route->getTarget('extension')); |
|
52 | - if (isset($this->route->getTarget()['callback'][$this->route->getTarget('extension')])) |
|
53 | - $this->response->setContent(call_user_func_array($this->route->getTarget()['callback'][$this->route->getTarget('extension')], [$this->route])); |
|
54 | - else { |
|
50 | + if ($this->response->getStatusCode() == 202) { |
|
51 | + $this->setContentType($this->route->getTarget('extension')); |
|
52 | + } |
|
53 | + if (isset($this->route->getTarget()['callback'][$this->route->getTarget('extension')])) { |
|
54 | + $this->response->setContent(call_user_func_array($this->route->getTarget()['callback'][$this->route->getTarget('extension')], [$this->route])); |
|
55 | + } else { |
|
55 | 56 | ob_start(); |
56 | 57 | require($this->route->getTarget('template')); |
57 | 58 | $this->response->setContent(ob_get_clean()); |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | /** |
25 | 25 | * @var array |
26 | 26 | */ |
27 | - private $matcher = ['matchClosure','matchController','matchTemplate']; |
|
27 | + private $matcher = ['matchClosure', 'matchController', 'matchTemplate']; |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * @var array |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | /** |
47 | 47 | * @param string $matcher |
48 | 48 | */ |
49 | - public function addMatcher($matcher){ |
|
49 | + public function addMatcher($matcher) { |
|
50 | 50 | $this->matcher[] = $matcher; |
51 | 51 | } |
52 | 52 | |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | /** |
62 | 62 | * @param array $dispatcher |
63 | 63 | */ |
64 | - public function setDispatcher($dispatcher = []){ |
|
65 | - $this->dispatcher = array_merge($dispatcher,$this->dispatcher); |
|
64 | + public function setDispatcher($dispatcher = []) { |
|
65 | + $this->dispatcher = array_merge($dispatcher, $this->dispatcher); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | private function generateTarget() |
124 | 124 | { |
125 | - if(is_callable($this->request['path'])){ |
|
125 | + if (is_callable($this->request['path'])) { |
|
126 | 126 | $this->router->route->setCallback($this->request['path']); |
127 | 127 | $this->router->route->setDetail($this->request); |
128 | 128 | $this->matchClosure(); |
@@ -135,11 +135,11 @@ discard block |
||
135 | 135 | ? $this->router->route->setCallback($this->request['path']['use']) |
136 | 136 | : $this->router->route->setCallback($this->request['path']); |
137 | 137 | $this->router->route->setDetail($this->request); |
138 | - if($this->validMethod()) { |
|
139 | - foreach($this->matcher as $matcher) |
|
140 | - call_user_func([$this,$matcher]); |
|
138 | + if ($this->validMethod()) { |
|
139 | + foreach ($this->matcher as $matcher) |
|
140 | + call_user_func([$this, $matcher]); |
|
141 | 141 | $this->router->response->setStatusCode(202); |
142 | - }else |
|
142 | + } else |
|
143 | 143 | $this->router->response->setStatusCode(405); |
144 | 144 | } |
145 | 145 | return $this->router->route->hasTarget(); |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | $index = isset($this->request['index']) ? $this->request['index'] : 0; |
182 | 182 | $class = (class_exists($routes[0])) |
183 | 183 | ? $routes[0] |
184 | - : $this->router->collection->getRoutes()['namespace_'.$index].$routes[0]; |
|
184 | + : $this->router->collection->getRoutes()['namespace_' . $index] . $routes[0]; |
|
185 | 185 | if (!class_exists($class)) |
186 | 186 | throw new \Exception('Class "' . $class . '." is not found'); |
187 | 187 | if (method_exists($class, $routes[1])) { |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | $extension = explode('.', $path); |
210 | 210 | $extension = end($extension); |
211 | 211 | $index = isset($this->request['index']) ? $this->request['index'] : 0; |
212 | - $block = $this->router->collection->getRoutes('path_'.$index); |
|
212 | + $block = $this->router->collection->getRoutes('path_' . $index); |
|
213 | 213 | if (in_array('.' . $extension, $this->router->getConfig()['viewExtension'])) { |
214 | 214 | if (is_file($block . $path)) { |
215 | 215 | $target = $block . $path; |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | throw new \Exception('Template file "' . $path . '" is not found in "' . $block . '"'); |
226 | 226 | } else { |
227 | 227 | foreach ($this->router->getConfig()['viewExtension'] as $ext) { |
228 | - if (is_file($block . $path . $ext)){ |
|
228 | + if (is_file($block . $path . $ext)) { |
|
229 | 229 | $target = $block . $path . $ext; |
230 | 230 | $extension = explode('.', $ext); |
231 | 231 | $extension = end($extension); |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | return true; |
240 | 240 | } |
241 | 241 | } |
242 | - throw new \Exception('Template file "' . $path . '" is not found in "' .$block . '"'); |
|
242 | + throw new \Exception('Template file "' . $path . '" is not found in "' . $block . '"'); |
|
243 | 243 | } |
244 | 244 | } |
245 | 245 | return false; |