Pheasant\Finder\Wizard::dispatch PHP Méthode

dispatch() public méthode

Magically derives a query to send to the internal finder
public dispatch ( $method, $params ) : mixed
Résultat mixed Either a Collection or a DomainObject
    public function dispatch($method, $params)
    {
        // find() and all() are aliases
        if ($method == 'find' && empty($params) || $method == 'all') {
            return $this->find();
        } else {
            if (($method == 'find' || $method == 'one') && is_string($params[0])) {
                $rs = $this->find(new Criteria(array_shift($params), $params));
                return $method == 'one' ? $rs->one() : $rs;
            } else {
                if (preg_match('/^(findBy|oneBy)/', $method)) {
                    $rs = $this->find(new Criteria($this->_sqlFromMethod($method), $params));
                    return preg_match('/^(oneBy)/', $method) ? $rs->one() : $rs;
                } else {
                    if ($method == 'byId') {
                        return $this->_findById($params);
                    } else {
                        if (isset($params[0]) && $params[0] instanceof Criteria) {
                            return $this->find($params[0]);
                        } else {
                            throw new \BadMethodCallException("Unable to dispatch '{$method}' to finder");
                        }
                    }
                }
            }
        }
    }