public function __call($name, $arguments) { $flags = $this->cachedFlags(); if (isset($flags[strtolower($name)])) { return $this->withFlag($name); } return parent::__call($name, $arguments); }
public function __call($name, $args) { $this->initRelation(); if (isset($this->__relations[$name])) { if (is_numeric($args[0])) { $this->__page[$name] = $args[0]; if (count($args) == 2 && is_numeric($args[1])) { $this->__pageSize[$name] = $args[1]; } $criteria = $this->relPagingCriteria($name); } else { if (is_array($args[0])) { $opt = $args[0]; $setRelPaging = false; if (isset($opt['page'])) { $this->__page[$name] = $opt['page']; unset($opt['page']); $setRelPaging = true; } if (isset($opt['pageSize'])) { $this->__pageSize[$name] = $opt['pageSize']; unset($opt['pageSize']); } if ($setRelPaging) { $criteria = $this->relPagingCriteria($name); $criteria = array_merge($criteria, $opt); } else { $criteria = $opt; } } } $this->loadRelation($name, @$criteria); $this->applyRelChange($name); return $this->__relations[$name]; } else { return parent::__call($name, $args); } }
/** * Added an override to __call to create the addRELATION() and removeRELATION() methods * PHP setter magic method. * @param string $name property name * @param mixed $value property value */ public function __call($name, $parameters) { if (strpos($name, 'add') === 0) { $relation = lcfirst(substr($name, 3)); if ($this->getManyManyRelation($relation)) { if (!empty($parameters)) { return $this->addRelated($relation, $parameters[0]); } elseif (count($parameters) > 1) { throw new CException('Too many parameters.'); } else { throw new CException('You must pass in a related model to add.'); } } } if (strpos($name, 'remove') === 0) { $relation = lcfirst(substr($name, 6)); if ($this->getManyManyRelation($relation)) { if (!empty($parameters)) { return $this->removeRelated($relation, $parameters[0]); } elseif (count($parameters) > 1) { throw new CException('Too many parameters.'); } else { throw new CException('You must pass in a related model to add.'); } } } return parent::__call($name, $parameters); }