[Solar-talk] Private communication channels between action and view

Jeff Moore jeff at procata.com
Sun Apr 20 16:22:41 CDT 2008


Hi,

As far as I know now, the current communication channel for sending  
data from an action to the view is to declare a public properity,

public $data;

set it in the action:

$this->data = $data;

And then read it in the view:

echo $this->data;

This has a delightful symmetry about it.  However, it turns out that  
if a controller has many views and actions (say 20), then the  
controller class must define all of the properties that correspond to  
all of the parameters to all of its views.

These property definitions then become a large chunk of code in the  
controller.  Its hard to see which property belongs to which action  
and which view.  More interesting properties are obscured by the  
declaration of view parameters.

Additionally, I'm seeing that in the heat of making changes, some  
names get chosen for these that make sense in the local contents (like  
$list or $item) that make little sense at the public property level.

Breaking up controllers does not solve the problem and is not easy  
because each controller correspond to an url segment in the site.

I'm also seeing that these property definitions don't get removed if  
their corresponding action assignments and view references are removed.

I think there is a problem of locality and scope with this method of  
communication between the controller and the view.

So, is there a way to communicate parameters to the view that can  
remain private between the view and the action?

Best Regards,

Jeff


More information about the Solar-talk mailing list