Index: library/Zend/Application/Resource/Frontcontroller.php =================================================================== --- library/Zend/Application/Resource/Frontcontroller.php (revision 24628) +++ library/Zend/Application/Resource/Frontcontroller.php (working copy) @@ -135,6 +135,22 @@ } break; + case 'dispatcher': + if(!isset($value['class'])) { + require_once 'Zend/Application/Exception.php'; + throw new Zend_Application_Exception('You must specify both '); + } + if (!isset($value['params'])) { + $value['params'] = array(); + } + + $dispatchClass = $value['class']; + if(!class_exists($dispatchClass)) { + require_once 'Zend/Application/Exception.php'; + throw new Zend_Application_Exception('Dispatcher class not found!'); + } + $front->setDispatcher(new $dispatchClass((array)$value['params'])); + break; default: $front->setParam($key, $value); break; Index: tests/Zend/Application/Resource/FrontcontrollerTest.php =================================================================== --- tests/Zend/Application/Resource/FrontcontrollerTest.php (revision 24628) +++ tests/Zend/Application/Resource/FrontcontrollerTest.php (working copy) @@ -388,8 +388,31 @@ $front = $resource->getFrontController(); $this->assertTrue($front->returnResponse()); } + + /** + * @group ZF-9724 + */ + public function testShouldSetDispatcherFromConfiguration() + { + require_once 'Zend/Application/Resource/Frontcontroller.php'; + $resource = new Zend_Application_Resource_Frontcontroller(array( + 'dispatcher' => array( + 'class' => 'ZF9724_Dispatcher', + 'params' => array( + 'bar' => 'baz' + ) + ) + )); + $resource->init(); + $front = $resource->getFrontController(); + $this->assertEquals('ZF9724_Dispatcher', get_class($front->getDispatcher())); + $this->assertEquals('baz', $front->getDispatcher()->getParam('bar')); + } } +require_once 'Zend/Controller/Dispatcher/Standard.php'; +class ZF9724_Dispatcher extends Zend_Controller_Dispatcher_Standard {} + if (PHPUnit_MAIN_METHOD == 'Zend_Application_Resource_FrontcontrollerTest::main') { Zend_Application_Resource_FrontcontrollerTest::main(); } Index: documentation/manual/en/module_specs/Zend_Application-AvailableResources-Frontcontroller.xml =================================================================== --- documentation/manual/en/module_specs/Zend_Application-AvailableResources-Frontcontroller.xml (revision 24628) +++ documentation/manual/en/module_specs/Zend_Application-AvailableResources-Frontcontroller.xml (working copy) @@ -98,6 +98,27 @@ boolean; by default, this is disabled. + + + + dispatcher: allows overriding the default + dispatcher. Has two subkeys, class (the classname of new dispatcher) + and params, an array of parameters to pass to the dispatcher constructor. + + + + Overriding the dispatcher + + + + + +