public function dispatch($method, $params)
    {
        // find() and all() are aliases
        if (($method == 'find' && empty($params)) || $method == 'all') {
            return $this->find();
        }

        // handle find or one with sql params
        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;
        }

        // handle magical finders
        else if (preg_match('/^(findBy|oneBy)/', $method)) {
            $rs = $this->find(new Criteria($this->_sqlFromMethod($method), $params));

            return preg_match('/^(oneBy)/', $method) ? $rs->one() : $rs;
        }

        // handle byId
        else if ($method == 'byId') {
            return $this->_findById($params);
        }

        // Criteria search
        else if (isset($params[0]) && $params[0] instanceof Criteria) {
            return $this->find($params[0]);
        }

        // failed to wizard :(
        else {
            throw new \BadMethodCallException("Unable to dispatch '$method' to finder");
        }
    }
public function dispatch($method, $params)
    {
        // find() and all() are aliases
        if (($method == 'find' && empty($params)) || $method == 'all') {
            return $this->find();
        }

        // handle find or one with sql params
        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;
        }

        // handle magical finders
        else if (preg_match('/^(findBy|oneBy)/', $method)) {
            $rs = $this->find(new Criteria($this->_sqlFromMethod($method), $params));

            return preg_match('/^(oneBy)/', $method) ? $rs->one() : $rs;
        }

        // handle byId
        else if ($method == 'byId') {
            return $this->_findById($params);
        }

        // Criteria search
        else if (isset($params[0]) && $params[0] instanceof Criteria) {
            return $this->find($params[0]);
        }

        // failed to wizard :(
        else {
            throw new \BadMethodCallException("Unable to dispatch '$method' to finder");
        }
    }
public function dispatch ( $ method , $ params ) { // find() and all() are aliases if ( ( $ method == 'find' && empty ( $ params ) ) || $ method == 'all' ) { return $ this -> find ( ) ; } // handle find or one with sql params 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 ; } // handle magical finders else if ( preg_match ( '/^(findBy|oneBy)/' , $ method ) ) { $ rs = $ this -> find ( new Criteria ( $ this -> _sqlFromMethod ( $ method ) , $ params ) ) ; return preg_match ( '/^(oneBy)/' , $ method ) ? $ rs -> one ( ) : $ rs ; } // handle byId else if ( $ method == 'byId' ) { return $ this -> _findById ( $ params ) ; } // Criteria search else if ( isset ( $ params [ 0 ] ) && $ params [ 0 ] instanceof Criteria ) { return $ this -> find ( $ params [ 0 ] ) ; } // failed to wizard :( else { throw new \ BadMethodCallException ( "Unable to dispatch '$method' to finder" ) ; } }
Magically derives a query to send to the internal finder
@return mixed Either a Collection or a DomainObject
Magically derives a query to send to the internal finder