[Solar-talk] $this->output Discussion
Raymond Kolbe
rkolbe at gmail.com
Thu Sep 13 08:44:51 CDT 2007
Yeah I did think about readability/documentation.
Also, I adopted (a while back) your method of using an array to hold
the forms...I like it ;-)
Thanks for the input Antti & Rodrigo.
On 9/12/07, Rodrigo Moraes <rodrigo.moraes at gmail.com> wrote:
> > On 9/12/07, Raymond Kolbe <rkolbe at gmail.com> wrote:
> > > Such as...you would just call `get()` or `set()` to do just that...get
> > > and set your data members.
> > >
> > > As I am writing this I am starting to think it would not be a great
> > > idea since you should never have to declare a lot of data members for
> > > output anyways. Most of the text/data that you would want to output
> > > would probably come from other objects.
> > >
> > > Anyways, here is what I came up with (straight forward) and I think I
> > > might implement it in one of my projects. Let me know what you all
> > > think -- pros? cons?
> > >
> > > http://pastebin.com/m4ac35c79
>
> Hi. The biggest "con" is to lose control over which variables the
> controller has and can use. Freely assigning vars is immediately
> practical, but can become a mess imo. Declaring those vars is a way to
> document them and know which are available. But... if you think it is
> not that bad, there are several workarounds you can made - and yours
> looks good. :)
>
> I use an array for forms, so I don't need to set a variable for forms
> on each controller - instead, I have $forms['my_form_name'] - $forms
> is in the base application since almost all pages have a form anyway.
> Similarly, Solar_App_Base has other arrays grouping variables by type
> ($layout_head, for example).
>
> > Solar_View has a method assign() which it uses to assign variables.
> > You can use it in your controllers like this:
> >
> > $this->_view_object->assign('var', 'value');
>
> Yes, and it is easy to assign an associative array, like in Raymond's idea:
>
> $this->_view_object->assign($this->output);
>
> Keys will be used as variable names, so with $this->output =
> array('foo' => 'bar'), you will have $this->foo available in the view
> templates (so it would not be necessary to use get() there).
>
> - rodrigo
> _______________________________________________
> Solar-talk mailing list
> Solar-talk at lists.solarphp.com
> http://mailman-mail3.webfaction.com/listinfo/solar-talk
>
More information about the Solar-talk
mailing list