@@ -51,17 +51,21 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | if ($count == count($this->route->getParameters()) || ($this->route->getParameters() == '' && $count == 0)) { |
| 53 | 53 | $dependencies = array_merge($dependencies, ($this->route->getParameters() == '') ? [] : $this->route->getParameters()); |
| 54 | - if ($this->response->getStatusCode() == 202) |
|
| 55 | - $this->response->setStatusCode(200); |
|
| 54 | + if ($this->response->getStatusCode() == 202) {
|
|
| 55 | + $this->response->setStatusCode(200); |
|
| 56 | + } |
|
| 56 | 57 | if (is_array($content = $reflectionMethod->invokeArgs($this->getController(), $dependencies))) { |
| 57 | 58 | $this->route->addTarget('data', $content); |
| 58 | 59 | if (isset($this->route->getParams()['ajax']) && $this->route->getParams()['ajax'] === true) { |
| 59 | 60 | $this->response->setContent(json_encode($content)); |
| 60 | 61 | $this->response->setHeaders(['Content-Type' => 'application/json']); |
| 61 | 62 | } |
| 62 | - } elseif (!is_null($content)) $this->response->setContent($content); |
|
| 63 | - } else |
|
| 64 | - $this->response->setStatusCode(404); |
|
| 63 | + } elseif (!is_null($content)) {
|
|
| 64 | + $this->response->setContent($content); |
|
| 65 | + } |
|
| 66 | + } else {
|
|
| 67 | + $this->response->setStatusCode(404); |
|
| 68 | + } |
|
| 65 | 69 | } |
| 66 | 70 | |
| 67 | 71 | |
@@ -72,8 +76,9 @@ discard block |
||
| 72 | 76 | private function getController() |
| 73 | 77 | { |
| 74 | 78 | $reflector = new ReflectionClass($this->route->getTarget('controller')); |
| 75 | - if (!$reflector->isInstantiable()) |
|
| 76 | - throw new \Exception('Target [' . $this->route->getTarget('controller') . '] is not instantiable.'); |
|
| 79 | + if (!$reflector->isInstantiable()) {
|
|
| 80 | + throw new \Exception('Target [' . $this->route->getTarget('controller') . '] is not instantiable.');
|
|
| 81 | + } |
|
| 77 | 82 | $constructor = $reflector->getConstructor(); |
| 78 | 83 | if (is_null($constructor)) { |
| 79 | 84 | $class = $this->route->getTarget('controller'); |