public function __call($method, $params) { if (substr($method, -10) == 'RelatedIDs') { ModelRelation::getInstanceForModel($this)->{$method}($this, $params[0], $params[1]); return $this; } elseif (substr($method, 0, 10) == 'setRelated') { ModelRelation::getInstanceForModel($this)->setRelatedIDs($this, substr($method, 10), $params[0]); return $this; } elseif (substr($method, 0, 12) == 'clearRelated') { ModelRelation::getInstanceForModel($this)->clearRelatedIDs($this, substr($method, 12), empty($params[0]) ? array() : $params[0]); return $this; } elseif ($methodInfo = ModelOperator::getInstanceAbilityMethod($this->_name, $method)) { array_unshift($params, $this); call_user_func_array(array($methodInfo['ability'], $method), $params); return $this; } elseif (substr($method, 0, 3) == 'set') { $this->offsetSet(Inflector::underscore(substr($method, 3)), $params[0]); return $this; } elseif (substr($method, 0, 3) == 'get') { return $this->offsetGet(Inflector::underscore(substr($method, 3))); } throw new \Exception('Undefined method for model: ' . $method); }
public function __call($method, $params) { if (substr($method, -10) == 'RelatedIDs') { ModelRelation::getInstanceForModel($this)->{$method}($this, $params[0], $params[1]); } elseif (substr($method, 0, 10) == 'setRelated') { ModelRelation::getInstanceForModel($this)->setRelatedIDs($this, substr($method, 10), $params[0]); } elseif (substr($method, 0, 12) == 'clearRelated') { ModelRelation::getInstanceForModel($this)->clearRelatedIDs($this, substr($method, 12), $params[0]); } elseif (in_array($method, $this->_modelsMethods)) { foreach ($this->_data as $object) { /** * @var Model $object */ call_user_func_array(array($object, $method), $params); } } elseif ($methodInfo = ModelOperator::getInstanceAbilityMethod($this->_modelClass, $method)) { array_unshift($params, $this); return call_user_func_array(array($methodInfo['ability'], $method), $params); } return $this; }