Skip to content

Instantly share code, notes, and snippets.

@harikt
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harikt/ee3c7b7581be53f20478 to your computer and use it in GitHub Desktop.
Save harikt/ee3c7b7581be53f20478 to your computer and use it in GitHub Desktop.
In first example the `modify()` is calling the `modifyWebRouter()` and `modifyWebDispatcher()` .
<?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')
);
}
}
<?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