diff --git a/src/Foundation/Controller.php b/src/Foundation/Controller.php index f400848..ee816b5 100644 --- a/src/Foundation/Controller.php +++ b/src/Foundation/Controller.php @@ -29,8 +29,11 @@ class Controller */ public function __construct( ContainerInterface $container, - string $controller, int $returnType = Response::HTML, ?array $args = null) - { + string $controller, + int $returnType = Response::HTML, + ?array $args = null + ) { + $this->container = $container; $this->controller = $controller; $this->returnType = $returnType; @@ -63,13 +66,15 @@ private function autowiredResponse() : void } $controllerConstructorArguments = Resolver::getParameterHints($this->controllerClass, '__construct'); $arguments = []; - foreach ($controllerConstructorArguments as $argumentName =>$argumentType) { + foreach ($controllerConstructorArguments as $argumentName => $argumentType) { $arguments[] = $this->getArgument($argumentName, $argumentType); } $reflectionClass = new ReflectionClass($this->controllerClass); $controller = $reflectionClass->newInstanceArgs($arguments); $this->actionOutput = $controller->__invoke(); - if (isset($this->actionOutput['meta']['type']) && $this->actionOutput['meta']['type'] === Dispatcher::REDIRECT) { + if (isset($this->actionOutput['meta']['type']) + && $this->actionOutput['meta']['type'] === Dispatcher::REDIRECT + ) { $this->returnType = Router::REDIRECT; } } @@ -77,9 +82,9 @@ private function autowiredResponse() : void private function getArgument(string $argumentName, string $argumentType) { if ($argumentType === Resolver::ARRAY) { - return $this->container->has($argumentName) ? $this->container->get($argumentName) : $this->{$argumentName}; + return $this->container->has($argumentName) ? + $this->container->get($argumentName) : $this->{$argumentName}; } return $this->container->get($argumentType); } - -} \ No newline at end of file +} diff --git a/src/Foundation/Response.php b/src/Foundation/Response.php index 65287c6..5c51707 100644 --- a/src/Foundation/Response.php +++ b/src/Foundation/Response.php @@ -145,7 +145,8 @@ private function renderResponse(int $returnType, array $actionOutput, string $co $paths = explode("\\", $controllerClass); $templateFile = array_pop($paths); $templateFolder = array_pop($paths); - $template = CaseConverter::toSnakeCase($templateFolder) . '/' . CaseConverter::toSnakeCase($templateFile) . '.twig'; + $template = CaseConverter::toSnakeCase($templateFolder) + . '/' . CaseConverter::toSnakeCase($templateFile) . '.twig'; $this->checkTemplateFile($template, 'Method\'s', $controllerClass); $actionOutput['data'] = $actionOutput['data'] ?? []; $output = [