-- Xavier <[EMAIL PROTECTED]> wrote
(on Friday, 29 September 2006, 12:50 PM +0200):
> Andries Seutens a ?crit :
> > Please see JIRA issue ZF-287 
> > (http://framework.zend.com/issues/browse/ZF-287)
> 
> thanks for your reply, yep, i'll wait for this modification, it would be 
> very usefull if we can override run()

In the MVC reorganization proposal:

    http://framework.zend.com/wiki/display/ZFPROP/MVC+Reorganization+Proposal
    
run() will no longer be used to dispatch an action unless using the
controller as a page controller. Two new methods, preRun() and postRun()
(names are still being discussed), will be called to bookend the action,
however, which will allow for the type of flexibility you describe in
one of your previous posts. As an example:

    class MyController
    {
        public function preRun()
        {
            if (!$this->_auth->isValid()) {
                // Require valid authentication token
                $this->_request->setController('login');
                $this->_request->setAction('form');
                return $this->_request;
            }
        }

        public function someAction()
        {
            // ...
        }

        public function postRun()
        {
            // Render content in a sitewide template
            $this->_view->body = $this->_body;
            $this->_view->display('site_template.phtml');
        }
    }

The preRun() above checks to see if the user is logged in; if not, the
user is redirected to the login form. In the postRun(), the generated
content gets assigned to a sitewide template, and then that template is
rendered.

If you use an action controller as a page controller, run() will be
invoked in order to dispatch the action. In the new incarnation, it will
no longer be final, allowing the developer to determine their own
routing mechanism.

-- 
Matthew Weier O'Phinney
PHP Developer            | [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/

Reply via email to