Skip to content
This repository was archived by the owner on Dec 6, 2022. It is now read-only.

Conversation

cawa87
Copy link

@cawa87 cawa87 commented Nov 12, 2014

I think it would be nice if router will have something like this.

@cawa87 cawa87 mentioned this pull request Nov 12, 2014
@malukenho
Copy link

@CawaKharkov very good!

I thinking in anything more simple, like that:

$dependency = new Dependency('Controller\Index::listPost', function() {
       $connector = PHPRouter\Di::getDependency('PDO');

       return new Controller\Index::listPost($connector);   
});

PHPRouter\Di::registerDependency($dependency);

$collection = new PHPRouter\RouteCollection();
$collection->attach(new Route('/posts/', array(
    '_controller' => 'Controller\Index::listPost',
    'methods' => 'GET'
)));

$router = new PHPRouter\Router($collection, $dependency);
$router->setBasePath('/');

The dependency can be passed to the PHPRouter Constructor, and process this internally.
In anyway It's a BC Break.

@cawa87
Copy link
Author

cawa87 commented Nov 13, 2014

@malukenho And where you will set the services that u need to inject?
And the router already creating instance in dispatch action, I think not a good idea to create it before.

@malukenho
Copy link

Closed in favor of #89

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants