Beispiel #1
0
 /**
  * Search the mixin method map and call the method or trigger an error
  *
  * This function implements a just in time mixin strategy. Available table behaviors are only mixed when needed.
  * Lazy mixing is triggered by calling DatabaseRowsetTable::is[Behaviorable]();
  *
  * @param  string     $method    The function name
  * @param  array      $arguments The function arguments
  * @throws \BadMethodCallException     If method could not be found
  * @return mixed The result of the function
  */
 public function __call($method, $arguments)
 {
     if ($this->isConnected()) {
         $parts = StringInflector::explode($method);
         //Check if a behavior is mixed
         if ($parts[0] == 'is' && isset($parts[1])) {
             if (!$this->isMixedMethod($method)) {
                 //Lazy mix behaviors
                 $behavior = strtolower($parts[1]);
                 if ($this->getTable()->hasBehavior($behavior)) {
                     $this->mixin($this->getTable()->getBehavior($behavior));
                 } else {
                     return false;
                 }
             }
         }
     }
     return parent::__call($method, $arguments);
 }