Last active
August 29, 2015 14:04
-
-
Save harikt/ee3c7b7581be53f20478 to your computer and use it in GitHub Desktop.
In first example the `modify()` is calling the `modifyWebRouter()` and `modifyWebDispatcher()` .
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Aura\Framework_Project\_Config; | |
use Aura\Di\Config; | |
use Aura\Di\Container; | |
class Common extends Config | |
{ | |
public function define(Container $di) | |
{ | |
// some definitions | |
} | |
public function modify(Container $di) | |
{ | |
$this->modifyWebRouter($di); | |
$this->modifyWebDispatcher($di); | |
} | |
public function modifyWebRouter(Container $di) | |
{ | |
$router = $di->get('web_router'); | |
$router->add('hello', '/') | |
->setValues(array('controller' => 'hello')); | |
$request = $di->get('web_request'); | |
$response = $di->get('web_response'); | |
$router | |
->add('blog.read', '/blog/read/{id}') | |
->addValues(array( | |
'controller' => 'blog.read' | |
)); | |
} | |
public function modifyWebDispatcher($di) | |
{ | |
$dispatcher = $di->get('web_dispatcher'); | |
$dispatcher->setObject('hello', function () use ($di) { | |
$response = $di->get('web_response'); | |
$response->content->set('Hello World!'); | |
}); | |
$dispatcher->setObject( | |
'blog.read', | |
$di->lazyNew('App\Actions\BlogRead') | |
); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Aura\Framework_Project\_Config; | |
use Aura\Di\Config; | |
use Aura\Di\Container; | |
class Common extends Config | |
{ | |
public function define(Container $di) | |
{ | |
// some definitions | |
} | |
public function modify(Container $di) | |
{ | |
$router = $di->get('web_router'); | |
$router->add('hello', '/') | |
->setValues(array('controller' => 'hello')); | |
$request = $di->get('web_request'); | |
$response = $di->get('web_response'); | |
$router | |
->add('blog.read', '/blog/read/{id}') | |
->addValues(array( | |
'controller' => 'blog.read' | |
)); | |
$dispatcher = $di->get('web_dispatcher'); | |
$dispatcher->setObject('hello', function () use ($di) { | |
$response = $di->get('web_response'); | |
$response->content->set('Hello World!'); | |
}); | |
$dispatcher->setObject( | |
'blog.read', | |
$di->lazyNew('App\Actions\BlogRead') | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment