Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>in Zend philosophy, they provide the init() method to avoid the hassle of</p> <pre><code>public class Module_TotoController extends Zend_Action_Controller { public function __construct(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response, array $invokeArgs = array()) parent::__construct($request, $response, invokeArgs); // some init code here } } </code></pre> <p>just use :</p> <pre><code>public class Module_TotoController extends Zend_Action_Controller { public function init () // some init code here } } </code></pre> <p>Now, If you look at the <code>Zend_Controller_Action</code> class source, you will notice that the following methods are <strong>empty</strong>:</p> <ul> <li><code>init()</code></li> <li><code>preDispatch ()</code></li> <li><code>postDispatch ()</code></li> </ul> <p>This means, it is useless to call <strong><code>parent::</code></strong> in your specific controller</p> <pre><code>public class Module_TotoController extends Zend_Action_Controller { public function init () parent::init(); // useless ;-) but you can go for it // some init code here } } </code></pre> <hr> <p>Now, if you want to put an intermediate class between <code>Module_TotoController</code> and <code>Zend_Action_Controller</code>, you expose yourself to a big hassle as:</p> <ul> <li>Some controllers won't extend your "base" controller (e.g your ErrorController in your question) <ul> <li>so it is not a really a base of your application, is it ?</li> </ul></li> <li>If you put some logic in your init() of that "base", <ul> <li>you must call the <code>parent::</code> in your <code>init()</code>, </li> <li>all the developers in the project need to be aware of that</li> </ul></li> <li>You will ever add another little features to your "Base" controller <ul> <li>This will result to a big bloated file</li> <li>Loading/Initializing plenty of stuff you might not really need in that lambda controller <ul> <li>Do you need you database on every page ? <ul> <li>No: doesn't a <code>$this-&gt;_helper-&gt;connect();</code> look nice instead ?</li> <li>Yes: use a controller plugin</li> </ul></li> </ul></li> </ul></li> <li>This "Base" controller won't fit your other projects needs, so that class won't be reusable <ul> <li>Action helpers will</li> <li>Controller Plugins will</li> </ul></li> </ul> <p>Hope it makes sense</p>
    singulars
    1. This table or related slice is empty.
    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. This table or related slice is empty.
    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