Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

Commit

Permalink
CS fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mkorkmaz committed Jul 20, 2017
1 parent 25de23a commit 008a64d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
19 changes: 12 additions & 7 deletions src/Foundation/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -63,23 +66,25 @@ 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;
}
}

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);
}

}
}
3 changes: 2 additions & 1 deletion src/Foundation/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down

0 comments on commit 008a64d

Please sign in to comment.