@@ -42,12 +42,14 @@ discard block |
||
| 42 | 42 | { |
| 43 | 43 | $reflectionMethod = new ReflectionMethod($this->route->getTarget('controller'), $this->route->getTarget('action')); |
| 44 | 44 | $dependencies = []; |
| 45 | - foreach ($reflectionMethod->getParameters() as $arg) |
|
| 46 | - if (!is_null($arg->getClass())) |
|
| 47 | - $dependencies[] = call_user_func_array($this->route->getTarget('di'),[$arg->getClass()->name]); |
|
| 45 | + foreach ($reflectionMethod->getParameters() as $arg) {
|
|
| 46 | + if (!is_null($arg->getClass())) |
|
| 47 | + $dependencies[] = call_user_func_array($this->route->getTarget('di'),[$arg->getClass()->name]);
|
|
| 48 | + } |
|
| 48 | 49 | $dependencies = array_merge($dependencies,($this->route->getParameters() == '') ? [] : $this->route->getParameters()); |
| 49 | - if ($this->response->getStatusCode() == 202) |
|
| 50 | - $this->response->setStatusCode(200); |
|
| 50 | + if ($this->response->getStatusCode() == 202) {
|
|
| 51 | + $this->response->setStatusCode(200); |
|
| 52 | + } |
|
| 51 | 53 | return $this->response->setContent($reflectionMethod->invokeArgs($this->getController(), $dependencies)); |
| 52 | 54 | } |
| 53 | 55 | |
@@ -59,8 +61,9 @@ discard block |
||
| 59 | 61 | private function getController() |
| 60 | 62 | { |
| 61 | 63 | $reflector = new ReflectionClass($this->route->getTarget('controller')); |
| 62 | - if (!$reflector->isInstantiable()) |
|
| 63 | - throw new \Exception('Target [' . $this->route->getTarget('controller') . '] is not instantiable.'); |
|
| 64 | + if (!$reflector->isInstantiable()) {
|
|
| 65 | + throw new \Exception('Target [' . $this->route->getTarget('controller') . '] is not instantiable.');
|
|
| 66 | + } |
|
| 64 | 67 | $constructor = $reflector->getConstructor(); |
| 65 | 68 | if (is_null($constructor)) { |
| 66 | 69 | $class = $this->route->getTarget('controller'); |