The example in this article describes the usage of Zend Framework distributor. Share it with everyone for your reference, as follows:
Distribution is to obtain the request object, extract the module name, controller name, action name and optional parameters, and then instantiate the controller and call the entire action process.
If the module, controller or action is not found, the default value will be used.
The Zend_Controller_Dispatcher_Standard class specifies that the default value of each controller and action is index, and the default value of the module is default.
This class allows developers to change the default value settings through the setDEfaultController() method, setDefaultAction() method and setDefaultModule() method.
_forward()
Function: Call this method in any action and pass in the action, controller, module and optional parameters to enter a new action.
Case:
<?php public function fooAction(){ //定义动作 //转到当前控制器与模块中的其他动作中 $this->_forward('bar',null,null,array('baz'=>'bogus'));//第一个参数,表动作;第二个参数,表控制器;第三个参数表示模块 } public function barAction(){ //定义动作 //转到当前模块的其他控制器的动作中,FooController::bazAction() $this->_forward('baz','foo',null,array('baz'=>'bogus')); } public function bazAction(){ //转到其他控制器、其他模块中的动作,Foo_BarController::bazAction() $this->_forward('baz','bar','foo',array('baz'=>'bogus')); }
I hope this article will be helpful to everyone’s PHP programming based on the Zend Framework framework.
For more articles related to Zend Framework distributor usage examples, please pay attention to the PHP Chinese website!