Zend Framework distributor usage example, zendframework
This example describes the Zend Framework distributor usage. We will share this with you for your reference. The details are as follows:
Distribution is the process of obtaining the request object, extracting the module name, controller name, action name, and optional parameters, instantiating the controller, and calling the action.
If the module, controller, or action is not found, the default value is used.
The Zend_Controller_Dispatcher_Standard class specifies that the default value of each controller and action is index, and that of the module is default.
This class allows developers to change the default value through the setdefacontroller controller () method, setDefaultAction () method, and setdefamodule module () method.
_ Forward ()
Function:Call this method in any action, and input the action, controller, module, and optional parameters to enter the new action.
Case:
<? Phppublic function fooAction () {// define action // go to the current controller and other actions in the module $ this-> _ forward ('bar', null, null, array ('baz' => 'bogg'); // The first parameter, table action; the second parameter, table Controller; the third parameter, indicating the module} public function barAction () {// define the action // switch to the action of another controller of the current module. FooController: bazAction () $ this-> _ forward ('baz', 'foo ', null, array ('baz' => 'bogg');} public function bazAction () {// switch to other controllers and actions in other modules, Foo_BarController: bazAction () $ this-> _ forward ('baz', 'bar', 'foo', array ('baz' => 'bogg '));}