2009/4/30 Jeff Carouth <jcarouth@tamu.edu>
What I would like to do is to get a configuration object (that is created during bootstrapping) into the view helper that holds the credentials, etc. for the Twitter service model _without_ stuffing it into the Registry.
What I do now when I have a dependency in a view helper is to follow the convention of returning the view helper when you call his method:
class My_View_Helper_Sample extends...
{
public function sample($arg1 = null, $arg2 = null)
{
if (!func_get_args()) {
return $this;
}
}
}
In the bootstrap I grab the view object when I setup the layout and request the view helper, that is created from the view. Then I call setXXXX() on it passing my config.
Since setting configuration for all helpers that may not be used is wasteful, I have a single View_Helper_Info that holds the configuration for the application. Other helpers call $this->view->info('configurationParameterName');
--
Giorgio Sironi
Piccolo Principe & Ossigeno Scripter
http://ossigeno.sourceforge.net
没有评论:
发表评论