Ejemplo n.º 1
0
 public function __call($method, $arguments)
 {
     static $watched_methods = array('_choices_display', '_display', '_has_rule', '_has_admin', '_has_many_add', '_has_many_del', '_as_admin_widget', '_choices_array', '_is_related_changed', '_type_get', '_label_get', '_admin_get', '_id_get', '_value_set');
     foreach ($watched_methods as $watched_method) {
         // See if called method is a watched method
         if (strpos($method, $watched_method) !== FALSE) {
             $pieces = explode($watched_method, $method);
             if (!empty($pieces[0]) && !empty($pieces[1])) {
                 // Watched method is in the middle
                 return $this->{'_' . trim($watched_method, '_')}($pieces[0], array_merge(array($pieces[1]), $arguments));
             } else {
                 // Watched method is a prefix or suffix
                 return $this->{'_' . trim($watched_method, '_')}(str_replace($watched_method, '', $method), $arguments);
             }
         }
     }
     return parent::__call($method, $arguments);
 }
Ejemplo n.º 2
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 (property_exists($this, $short_key)) {
                 return $this->{$short_key};
             } else {
                 return NULL;
             }
         }
     }
     return parent::__call($key, $args);
 }