In-depth understanding of ZF distribution loop (how Dispatcher works)
Public function fooAction ()
- {
- // Forward to another action in the current controller and module:
- $ This-> _ forward ('bar', null, null, array ('Baz' => 'bogg '));
- }
Public function barAction ()
- {
- // Forward to an action in another controller, FooController: bazAction (),
- // In the current module:
- $ This-> _ forward ('Baz', 'foo', null, array ('Baz' => 'bogg '));
- }
Public function bazAction ()
- {
- // Forward to an action in another controller in another module,
- // Foo_BarController: bazAction ():
- $ This-> _ forward ('Baz', 'bar', 'foo', array ('Baz' => 'bogg '));
- }
- ?>
Conclusion: Dispatcher is an important part of ZF's implementation of MVC. Understanding the functions of Dipatcher is of great significance for us to better apply ZF or other frameworks. It can be considered that the allocation function is similar to a process that executes the corresponding behavior after the route, and then returns the response object. |