Prev | Current Page 51 | Next

Rob Allen, Nick Lo, and Steven Brown

"Zend Framework in Action"

The init() function is called whenever the controller class is
constructed. This makes it very similar to the standard constructor, except that it does not take any parameters
and does not require the parent function to be called.
preDispatch() and postDispatch() are a complementary pair of functions that are run before and after each
action function is called. For an application where only one action is run in response to a request, there is no
difference between init() and preDispatch() as each are only call once. If, however, the first action function
uses the _forward() function to pass control to another action function, then preDispatch() will be run again,
but init() will not be. To illustrate this point, we could use init() to ensure that only administrators are allowed
access to any action function in the controller and preDispatch() to set the correct view template file that will
be used by the action.
The Response
The final link in the front controller chain is the response. For a web application
Zend_Controller_Reponse_Http is provided, but if you are writing a command line application, then
Zend_Controller_Response_Cli would be more appropriate. The response object is very simple and is
essentially a bucket to hold all the output until the end of the controller processing.


Pages:
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
hosting zakłady bukmacherskie serwis drukarek katowice petrozawodzkich.waw.pl Biuro rachunkowe Wrocław