Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First <code>preDispatch()</code> is called for instances of <code>Zend_Controller_Plugin_Abstract</code>. Here you have the request and response objects, so you might filter the request or do some preparation using the information from the request.</p> <p><code>init()</code> of the <code>Zend_Controller_Action</code> is called next as part of the constructor. It's there to help you initialize your controller, without having to override and repeat the signature of the constructor (<code>Zend_Controller_Action::__contruct()</code>).</p> <p>The controller's <code>preDispatch()</code> method is called here. You can call <code>$request-&gt;setDispatched(false)</code> to skip the current action - not sure if you can do that in <code>init()</code></p> <p>Then your action method is called (<code>viewAction()</code> for example). Here you do your normal work like fetching stuff from the model and populating the view.</p> <p>So the distinction should now be clear: </p> <ul> <li>If you want something to be executed before all actions - put it in a plugin and use one of the hooks (besides <code>preDispatch()</code> there is <code>routeStartup</code> and <a href="http://framework.zend.com/manual/en/zend.controller.plugins.html" rel="noreferrer">others</a>),</li> <li>if you want before every action in a controller - <code>init</code> or <code>preDispatch()</code>,</li> <li>if only for a single action - the action itself.</li> </ul> <blockquote> <p>What happens between <code>init()</code> and <code>preDispatch()</code> function calls?</p> </blockquote> <p>Almost nothing - <code>preDispatch()</code> is executed, and if you haven't called <code>$request-&gt;setDispatched(false)</code>, the action is executed.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload