The SiteTemplate plug-in uses three hooks:
dispatchLoopStartup(), preDispatch() and dispatchLookShutdown().
Figure 3.5 shows a simplified view of the Zend Framework dispatch loop and where the SiteTemplate
plugin??™s hook functions get called during code the process.
Licensed to Menshu You
Please post comments or corrections to the Author Online forum at
http://www.manning-sandbox.com/forum.jspa?forumID=329
Figure 3.5: Front controller??™s dispatch loop
The dispatchLoopStartup() function is called after all routing is done, but before processing all the
controller actions. It is therefore an ideal place to initialize the view. The preDispatch() function is called
everytime a new controller action function is called. Usually there is only one controller action during a
request, however, it is possible to add more using the _forward() function or other front controller plug-ins. As
preDispatch() gets called every time, it is used to ensure that the view object is assigned the current names of
the module, controller and action. Finally dispatchLoopShutdown() is called after everything is done. It is
therefore the perfect time to render the master view template to complete the Two-Step view.
Let??™s look at the code. Listing 3.
Pages:
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100