I am trying to hack an ACL into a Template without making the Template aware of the ACL object in the class definition. The following code generates an undefined method Template::isAllowed
Why is this? TIA!
class ACL {
protected $allowed = array('anything');
public function isAllowed($what){
if(in_array($what, $this->allowed))
return true;
return false;
}
}
class Template extends stdClass { }
$Template = new Template;
$ACL = new ACL;
$Template->isAllowed = function($what) use($ACL) { return $ACL->isAllowed($what); };
if($Template->isAllowed('anything'))
echo 1;
else
echo 2;