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 | |
| $app->get('/hello/{name}', function ($name) use ($app) { | |
| return [ | |
| 'controller' => 'blog', | |
| 'action' => 'hello', | |
| 'name' => $name, | |
| 'app' => $app, | |
| ]; | |
| }); | |
| $app->on(KernelEvents::VIEW, function ($event) use ($app, $dispatcher) { | |
| $view = $event->getControllerResult(); | |
| if (is_null($view) || is_string($view)) { | |
| return; | |
| } | |
| if ( ! is_array($view)) { | |
| // we can only handle array data in the view | |
| return; | |
| } | |
| if (! (isset($view['controller'] && isset($view['action'])))) { | |
| // at this point we don't know what is going on. | |
| return; | |
| } | |
| $response = $dispatcher($view); | |
| if ( ! $response instanceof Response) { | |
| // If the response is not a Response instance, wrap it in one | |
| // and assume that it was something appropriate as a response | |
| // body. | |
| $response = new Response($response); | |
| } | |
| $event->setResponse($response); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you. I am updating the post http://harikt.com/blog/2013/11/06/using-aura-dispatcher-in-silex/