@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | /** |
| 28 | 28 | * @param Route $route |
| 29 | 29 | */ |
| 30 | - public function __construct(Route $route,ResponseInterface $response) |
|
| 30 | + public function __construct(Route $route, ResponseInterface $response) |
|
| 31 | 31 | { |
| 32 | 32 | $this->route = $route; |
| 33 | 33 | $this->response = $response; |
@@ -44,8 +44,8 @@ discard block |
||
| 44 | 44 | $dependencies = []; |
| 45 | 45 | foreach ($reflectionMethod->getParameters() as $arg) |
| 46 | 46 | if (!is_null($arg->getClass())) |
| 47 | - $dependencies[] = call_user_func_array($this->route->getTarget('di'),[$arg->getClass()->name]); |
|
| 48 | - $dependencies = array_merge($dependencies,($this->route->getParameters() == '') ? [] : $this->route->getParameters()); |
|
| 47 | + $dependencies[] = call_user_func_array($this->route->getTarget('di'), [$arg->getClass()->name]); |
|
| 48 | + $dependencies = array_merge($dependencies, ($this->route->getParameters() == '') ? [] : $this->route->getParameters()); |
|
| 49 | 49 | if ($this->response->getStatusCode() == 202) |
| 50 | 50 | $this->response->setStatusCode(200); |
| 51 | 51 | return $this->response->setContent($reflectionMethod->invokeArgs($this->getController(), $dependencies)); |
@@ -64,13 +64,13 @@ discard block |
||
| 64 | 64 | $constructor = $reflector->getConstructor(); |
| 65 | 65 | if (is_null($constructor)) { |
| 66 | 66 | $class = $this->route->getTarget('controller'); |
| 67 | - return call_user_func_array($this->route->getTarget('di'),[$class]); |
|
| 67 | + return call_user_func_array($this->route->getTarget('di'), [$class]); |
|
| 68 | 68 | } |
| 69 | 69 | $dependencies = $constructor->getParameters(); |
| 70 | 70 | $arguments = []; |
| 71 | 71 | foreach ($dependencies as $dep) { |
| 72 | 72 | $class = $dep->getClass()->name; |
| 73 | - array_push($arguments, call_user_func_array($this->route->getTarget('di'),[$class])); |
|
| 73 | + array_push($arguments, call_user_func_array($this->route->getTarget('di'), [$class])); |
|
| 74 | 74 | } |
| 75 | 75 | return $reflector->newInstanceArgs($arguments); |
| 76 | 76 | } |
@@ -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'); |