public function __call($name, $arguments)
{
// If no arguments are provided try mapping to the scopeSomething() method
if (empty($arguments)) {
$methodName = 'scope' . ucfirst($name);
if (method_exists($this, $methodName)) {
$this->{$methodName}();
return $this;
}
}
// Implements getNew($relationName)
if ($name == 'getNew' && count($arguments)) {
return $this->relationManager->getNew($arguments[0]);
}
// Magically map relations to methods, e.g. $this->foobar will return the "foobar" relations' contents
if ($this->relationManager->isMagicMethod($name)) {
return call_user_func_array(array($this->relationManager, $name), $arguments);
}
// Otherwise call the parent
return parent::__call($name, $arguments);
}