Exemplo n.º 1
0
 /**
  * Search the mixin method map and call the method or trigger an error
  *
  * This functions overloads KDatabaseRowAbstract::__call and implements 
  * a just in time mixin strategy. Available table behaviors are only mixed 
  * when needed.
  *
  * @param  string 	The function name
  * @param  array  	The function arguments
  * @throws BadMethodCallException 	If method could not be found
  * @return mixed The result of the function
  */
 public function __call($method, array $arguments)
 {
     // If the method hasn't been mixed yet, load all the behaviors.
     if (!isset($this->_mixed_methods[$method])) {
         foreach ($this->getTable()->getBehaviors() as $behavior) {
             $this->mixin($behavior);
         }
     }
     return parent::__call($method, $arguments);
 }
Exemplo n.º 2
0
 /**
  * Search the mixin method map and call the method or trigger an error
  *
  * This functions overloads KDatabaseRowAbstract::__call and implements
  * a just in time mixin strategy. Available table behaviors are only mixed
  * when needed.
  *
  * @param  string 	The function name
  * @param  array  	The function arguments
  * @throws BadMethodCallException 	If method could not be found
  * @return mixed The result of the function
  */
 public function __call($method, array $arguments)
 {
     if ($this->isConnected()) {
         $parts = KInflector::explode($method);
         //Check if a behavior is mixed
         if ($parts[0] == 'is' && isset($parts[1])) {
             if (!isset($this->_mixed_methods[$method])) {
                 //Lazy mix behaviors
                 $behavior = strtolower($parts[1]);
                 if ($this->getTable()->hasBehavior($behavior)) {
                     $this->mixin($this->getTable()->getBehavior($behavior));
                     return true;
                 }
                 return false;
             }
             return true;
         }
     }
     return parent::__call($method, $arguments);
 }
Exemplo n.º 3
0
 public function __call($method, $arguments)
 {
     if (method_exists($this->_message, $method)) {
         call_user_func_array(array($this->_message, $method), $arguments);
         return $this;
     } else {
         return parent::__call($method, $arguments);
     }
     //return method_exists($this->_message, $method) ? $this->_message->$method : parent::__call($method, $arguments);
 }