示例#1
0
 public function __call($key, $args = array())
 {
     $prfx = 'present_';
     if (substr($key, 0, strlen($prfx)) == $prfx) {
         $short_key = substr($key, strlen($prfx));
         $presenter = $this->presenter();
         if ($presenter === NULL) {
             // attempt to load presenter
             $presenter = HC_App::presenter($this->my_class(), $this);
             if ($presenter) {
                 $this->set_presenter($presenter);
             } else {
                 $this->set_presenter(FALSE);
             }
         }
         if ($presenter && method_exists($presenter, $short_key)) {
             array_unshift($args, $this);
             return call_user_func_array(array($presenter, $short_key), $args);
             // return $presenter->{$short_key}( $this );
         } else {
             if (isset($this->{$short_key})) {
                 return $this->{$short_key};
             }
         }
     }
     return parent::__call($key, $args);
 }