Skip to content

Commit

Permalink
di refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
StereoFlo committed Jan 14, 2019
1 parent c46f37d commit 8dff819
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
7 changes: 7 additions & 0 deletions config/container.php
@@ -0,0 +1,7 @@
<?php

/**
* DI config file
*/

$container = new \Core\Container();
7 changes: 3 additions & 4 deletions public/index.php
@@ -1,13 +1,12 @@
<?php

use Core\Container;
use Core\Request\Request;
use Core\Router\Router;

include_once '../src/bootstrap.php';
include_once '../config/container.php';

$container = new Container();
$request = Request::create();
$router = Router::create($request);
$request = Request::create();
$router = Router::create($request);

Application::create($request, $router, $container);
4 changes: 2 additions & 2 deletions src/Application.php
Expand Up @@ -84,7 +84,7 @@ private function run()
throw new \Exception('controller is not callable!');
}

$ref = new ReflectionClass($this->router->getRoute()->getController());
$ref = new \ReflectionClass($this->router->getRoute()->getController());
$resolveConstructorParams = [];
if (!empty($ref->getConstructor())) {
$resolveConstructorParams = $this->di($this->router->getRoute()->getController(), $ref->getConstructor()->getName());
Expand Down Expand Up @@ -130,7 +130,7 @@ private function getControllerPath(): string
private function di(string $controller, string $action): array
{
$result = [];
$method = new ReflectionMethod($controller, $action);
$method = new \ReflectionMethod($controller, $action);
$params = $method->getParameters();
if (empty($params)) {
return [];
Expand Down

0 comments on commit 8dff819

Please sign in to comment.