[Solar-talk] multiple controllers, one view
Matt M.
goodieboy at gmail.com
Sat Oct 21 14:16:15 PDT 2006
Hi,
I think it's great to have single instances of the request and session
classes. It only makes sense. I acually wanted to get to that at some
point...
One of the cool things about the "forwarding" controller is that it's
actually a chain. One way to look at how thata relates to views is; the
earlier the controller in the chain, the farther it is from the center of
the layout. So, the first controller could create (or later "wrap") a layout
for the child controllers response. I think it works pretty well, because
the final controller doesn't need to know about the layout around it's view.
And the same for the parent/previous controllers. They don't need to know
about the final controllers' view. They just create the outside layouts etc.
So for example, if you had an admin controller, it would wrap all child
controllers (content controller, user controller etc.) with an admin
template.
Not sure if that falls into 1 or 2, but that's the way I've done it for a
long time and really like it.
On 10/21/06, Rodrigo Moraes <rodrigo.moraes at gmail.com> wrote:
>
> Hi,
> I would like to ask your opinion about how to tie controllers and
> views. I've been working with the "forwarding" controller and it
> passes the request ahead to the next controller, until the last
> controller handles the request. So we end up with a bunch of
> controllers (two or three, in most cases), and all of them are a
> subclass of Forwarding_Controller.
>
> How to have an unique view for all these controllers? I see two options:
>
> 1. Instantiate the view on the first controller and store the view in
> a property. After each controller is created, the same view is
> assigned to it.
>
> 2. Register the view, and call it from registry when needed (this is
> intended to be used by Controller_Forwarding, not everywhere).
>
> I'm using the second option. Having a lot of "front"/"page"
> controllers are forcing me to use the registry perhaps more than I
> should: I'm storing Solar_View, Solar_Session, Solar_Request and
> Solar_Uri_Action instances in the registry. This avoids having to pass
> around objects to ensure they will be the same, or to create objects
> repeatedly. Is it bad to use the registry in these cases?
>
> Which approach would you prefer? Any other options?
>
> thanks,
> rodrigo
>
> ---------------------------------------------------------------------
> Solar has now a Community Wiki: solarphp.org
> ---------------------------------------------------------------------
> Join the #solarphp IRC channel on freenode.org
> ---------------------------------------------------------------------
> _______________________________________________
> solar-talk mailing list
> solar-talk at lists.solarphp.com
> http://mail.killersoft.com/mailman/listinfo/solar-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.killersoft.com/pipermail/solar-talk/attachments/20061021/c5c2c36b/attachment.htm
More information about the solar-talk
mailing list