/** * Dispatch the controller. * * @param \Es\Dispatcher\DispatchEvent $event The event of dispatch */ public function doDispatch(DispatchEvent $event) { $controller = $event->getContext(); $action = $event->getParam('action') . 'Action'; $server = $this->getServer(); $request = $server->getRequest()->withAddedAttributes($event->getParams()); $response = $server->getResponse(); $result = call_user_func_array([$controller, $action], [$request, $response]); $event->setResult($result); }
public function testConstructorOnSuccess() { $controller = new FakeController(); $params = ['foo' => 'bar']; $event = new DispatchEvent($controller, 'FakeController', 'fake', $params); $this->assertSame($controller, $event->getContext()); $this->assertSame('FakeController', $event->getParam('controller')); $this->assertSame('fake', $event->getParam('action')); $this->assertSame('bar', $event->getParam('foo')); $this->assertSame('FakeController@fake', $event->getName()); }