dispatch() public method

Dispatch another controller
public dispatch ( string $name, array $params = null ) : mixed
$name string Controller name; either a class name or an alias used in the controller manager
$params array Parameters with which to seed a custom RouteMatch object for the new controller
return mixed
示例#1
0
 public function testPluginWithoutLocatorAwareControllerRaisesDomainException()
 {
     $controller = new UnlocatableEventfulController();
     $controller->setEvent($this->controller->getEvent());
     $plugin     = new ForwardPlugin();
     $plugin->setController($controller);
     $this->setExpectedException('Zend\Mvc\Exception\DomainException', 'implements ServiceLocatorAwareInterface');
     $plugin->dispatch('forward');
 }
示例#2
0
 /**
  * compatibility with ModuleRouteListener
  *
  * @see Zend\Mvc\ModuleRouteListener
  */
 public function testShorNamedController()
 {
     $shortNamedController = 'forward-fq';
     $origCtlKey = ModuleRouteListener::ORIGINAL_CONTROLLER;
     $params = array(ModuleRouteListener::MODULE_NAMESPACE => 'ZendTest\\Mvc\\Controller\\TestAsset', 'action' => 'test', 'param1' => 'foo');
     $result = $this->plugin->dispatch($shortNamedController, $params);
     $this->assertInternalType('array', $result);
     $this->assertArrayHasKey('content', $result);
     $this->assertEquals('ZendTest\\Mvc\\Controller\\TestAsset\\ForwardFqController::testAction', $result['content']);
     $this->assertArrayHasKey('params', $result);
     $this->assertArrayHasKey($origCtlKey, $result['params']);
     $this->assertEquals($shortNamedController, $result['params'][$origCtlKey]);
 }
示例#3
0
 public function testPluginWithoutEventAwareControllerRaisesDomainException()
 {
     $controller = new UneventfulController();
     $plugin = new ForwardPlugin($this->controllers);
     $plugin->setController($controller);
     $this->setExpectedException('Zend\\Mvc\\Exception\\DomainException', 'InjectApplicationEventInterface');
     $plugin->dispatch('forward');
 }