-- benoit <[email protected]> wrote
(on Monday, 20 December 2010, 10:17 AM -0800):
> I believed that too. But i tested it and the dispatcher dispatch my
> request anyway.  When i look into the code, I saw in the
> frontController dispatch method, the dispatch loop is a "do ...
> while", so we passed into the boucle at least one time.  
>
> At line 936, there is a "$this->_request->setDispatched(true)" made,
> so even if I didn't do this in my plugin before, this is did there.
> At line 954, we enter into the dispatch function of dispatcher(I used
> the standard dispatcher).
> 
> In the standard dispatcher, at line 279, there is another
> "$request->setDispatched(true);", and the dispatch of my controller is
> call 20 line after.
> 
> In the dispatch of the controller action, we check is the request is
> dispatched, and if it's true, we call the controller's action.
> 
> So, I didn't find where the request is not dispatched, or the dispatch
> boucle is bypass, if we did "$this->_request->setDispatched(true)"
> 
> Is it possible?
> 
> And I have another question, why a "do..while" bouckle is made, and not a
> "while" ?

Because in the original development of the front controller, the
assumption was that, at some point, you'd need to execute an action in
order to get a response. Clearly, that assumption may no longer be
valid -- but changing from a do/while to a straight while loop would
potentially have huge ramifications for existing applications.

Consider this: somebody may want to report a bootstrap or plugin
exception via the ErrorController so that a nice error page, in the site
layout will be displayed; or they may have retrieved cached content, and
want it injected in the layout prior to display; etc. If we change the
code to a straight while() loop, we risk breaking such workflows.

As a result, the unfortunate second choice mechanism is to call exit()
after force-rendering content (this is what the Redirector does by
default).

In ZF2, we're attempting to solve these problems and limitations; we
likely cannot solve them in a BC-compatible way in ZF1.

-- 
Matthew Weier O'Phinney
Project Lead            | [email protected]
Zend Framework          | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc

Reply via email to