Matthew Weier O'Phinney a écrit
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.
Yep, thanks for this usefull info, i should have dig proposals before
posting ;)
I'll wait for this cool capabilities.
Cheers
Xavier