[Solar-talk] "Forwarding" Controller
Travis Swicegood
development at domain51.com
Wed Oct 18 22:30:11 PDT 2006
Hi All,
Rodrigo Moraes wrote:
> I like more and more the flexibility of the "forwarding" constructor
> idea. So I went to SitePoint forum to see if I could find anybody
> talking about a similar concept. I found that Konstrukt's developer is
> a member there, and below I pasted his description which explains very
> well how it works. So I ask what you, Solar users, think about this,
> and the pros and cons you see in this approach.
>
And I'll respond :-)
> ... snip ...
>
> "A hierarchical controller implementation doesn't have a fixed tree of
> execution. It doesn't have a front controller per se either. Instead
> there is a root controller, which is the entry point. This root
> basically works as a front controller, except that it doesn't decide
> the full route of the request - only a partial route. This is the
> difference to the two classical front controller implementations. The
> root controller will dispatch to the next controller in line. Exactly
> how many times this happens, depends on the request. Some may stop
> already at the root controller, others may go five or more levels down
> before reaching the final handler. So the execution tree for this
> design is variable in depth.
>
This is what I call a Nested Controller. A more logical, and possibly
easier to understand URL, might look something like this:
http://www.domain.com/index.php/site/bookmark/edit/?id=123
With this, your execution tree would look something like:
Front Controller::dispatch()
- return SiteController::dispatch()
- return Bookmark::edit()
Now the way I would implement this is that each is that each controller
checks for the presence of a "/" in the action it's being asked to
execute. If it's present, it realizes that no actions should take
place, but do call the _pre*/_post*() methods so you can use them to
wrap the other controller(s)s output.
This is very similar to the way Solar_App works, with one exception.
There's no URL reference to the Solar_App, so there's no way to
arbitrarily pull it out without adding a get parameter. This becomes an
issue with AJAX request where you don't want to put all of the display
around every request.
Now that I'm starting to get my bearings in Solar, I may put together a
nested controller: I'm thinking Domain51_Controller_Nested. I'll let
you guys know if anything of consequence comes from it.
-Travis
More information about the solar-talk
mailing list