FOF30\Model\DataModel::__call PHP Method

__call() public method

Magic caller. It works like the magic setter and returns ourselves for chaining. If no arguments are passed we'll only look for a scope filter.
public __call ( string $name, mixed $arguments ) : static
$name string
$arguments mixed
return static
    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);
    }

Usage Example

コード例 #1
0
ファイル: DataModelStub.php プロジェクト: Joal01/fof
 public function __call($method, $args)
 {
     if (isset($this->methods[$method])) {
         $func = $this->methods[$method];
         // Let's pass an instance of ourself, so we can manipulate other closures
         array_unshift($args, $this);
         return call_user_func_array($func, $args);
     }
     return parent::__call($method, $args);
 }