$this in HelperMethods
I think it because only vars are passed to the view file.
extract(get_object_vars($this),EXTR_REFS);
and secondly this method can work fin because the method "addMethod" doen't exist:
/**
* @param mixed String method name, or array of method name => callback pairs
* @param callback Callback function
*/
final public function addHelperMethod($method,$callback = false){
if(is_array($method))
foreach($method as $_method => $_callback)
$this->addMethod($_method,$_callback);
else
$this->__methods__[$method] = $callback;
}
Posted June 3rd, 2007 at 11:31am by philippe
I use this HelperMethod (defined in my ApplicationController which extends PicoraController:
The ApplicationController has an attribute "db" which is an handle to an instance to my database-class. The Helper-Method was added with the addHelperMethod from the view:
In the Template, I call the helper-method like this:
Now, PHP gives me the folowing error:
Why can't I use $this in the helper-methods? Where the helperMethods called the static way? Or have i made a mistake?
Thanks for answers, Aaron
Posted June 1st, 2007 at 1:33pm by Aaron