Magically derives a query to send to the internal finder
@return mixed Either a Collection or a DomainObject
766487
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");
        }
    }
1024171
public function findOne($query = [], $fields = [])
    {
        if (is_string($query)) {
            return $this->collection->findOne($query, $fields = []);
        }

        return parent::findOne($query, $fields);
    }
146668
public static function factoryFromWpQuery()
    {
        global $wp_query;

        if ((bool)$wp_query->is_tax) {
            $term = get_term_by("slug", $wp_query->query_vars['term'], $wp_query->query_vars['taxonomy']);
            return ModelEntity::factoryFromString($term->taxonomy, $term);
        }

        if ($wp_query->queried_object && get_class($wp_query->queried_object) === "WP_Term") {
            $term = $wp_query->queried_object;
            return ModelEntity::factoryFromString($term->taxonomy, $term);
        }
    }
1293706
public function query()
    {
        $query = app($this->model)->query()->where('resource', $this->resource->getMorphClass());

        return $this->applyScopes($query);
    }
98763
public function getQuery()
    {
        $query = $this->database->getSelectQuery()->from($this->table);

        foreach ($this->join as $join) {
            if (!is_array($join[2])) {
                $join[2] = [$join[2]];
            }

            $where = array_shift($join[2]);
            if (!empty($join[2])) {
                foreach ($join[2] as $i => $value) {
                    $join[2][$i] = $this->database->bind($value);
                }

                $where = vsprintf($where, $join[2]);
            }

            $query->join($join[0], $join[1], $where, $join[3]);
        }

        foreach ($this->filter as $i => $filter) {
            //array('post_id=%s AND post_title IN %s', 123, array('asd'));
            $where = array_shift($filter);
            if (!empty($filter)) {
                foreach ($filter as $i => $value) {
                    $filter[$i] = $this->database->bind($value);
                }

                $where = vsprintf($where, $filter);
            }

            $query->where($where);
        }

        return $query;
    }
120657
public function getResults()
    {
        $key = $this->dataKey;
        $content = $this->content;

        if (is_object($content) && property_exists($content, $key)) {
            return new Collection($content->{$key});
        } elseif (is_array($content)) {
            return new Collection($content);
        }

        return $content;
    }
1300571
protected function getListCollection()
    {
        $conditions = $this->query_filter;
        $conditions['limit'] = $this->data_limit;

        return (array) $this->collection->getList($conditions);
    }
356477
public function getPrimaryKeyQuery() {
        if (!empty($this->primaryKey)
            && $this->hasAttribute($this->primaryKey)) {
            return static::query()->where($this->primaryKey,
                $this->getAttributeSource($this->primaryKey));
        }
        return false;
    }
1259258
public function query()
    {
        // Query every server using it's domain name.
        for ($i = 0; $i < $this->numservers; $i++) {
            $result = $this->querySingleServer($this->server[$i]);
            if ($this->debug) {
                echo "server: {$this->server[$i]}\n";
                echo "result: $result\n";
            }

            if ($result) {
                return $result;
            }
        }
        return false;
    }
705294
public function query()
    {
        $this->applyCriteria();

        if ($this->model instanceof Model) {
            return $this->model->query();
        }

        return clone $this->model;
    }
122367
public function query() {
        $builder = $this->getServiceLocator()->get($this->builderClassName);
        $builder->setOptions($this->options)->setServiceLocator($this->serviceLocator);
        return $builder;
    }
341642
public function createQuery()
    {
        $query = $this->persistenceManager->createQueryForType($this->entityClassName);
        if ($this->defaultOrderings !== []) {
            $query->setOrderings($this->defaultOrderings);
        }
        return $query;
    }
1363105
public function getResults()
    {
        if (! is_array($this->getParentKey())) {
            return ! is_null($this->getParentKey()) ? $this->query->get() : $this->related->newCollection();
        }

        return $this->query->get();
    }
1336613
public function domainAction()
    {
        $request = $this->getRequest();
        $type    = $request->getParam( 'type' );
        $domain  = $request->getParam( 'domain' );

        if ( ! $request instanceof ConsoleRequest )
        {
            throw new \RuntimeException( sprintf(
                '%s can only be used from a console.',
                __METHOD__
            ) );
        }

        $siteInfo = $this->getServiceLocator()
                         ->get( 'SiteInfo' );

        if ( $domain != $siteInfo->getDomain() )
        {
            throw new \RuntimeException( sprintf(
                '%s: domain mismatch. Detected "%s", while enforced "%s".',
                __METHOD__,
                $siteInfo->getDomain(),
                $domain
            ) );
        }

        $locator    = $this->getServiceLocator();
        $config     = $locator->get( 'Configuration' );

        if ( empty( $config['modules']['Grid\Core']['cron'] ) )
        {
            return '';
        }

        $result     = '';
        $keys       = array( 'site' );
        $cronConfig = $config['modules']['Grid\Core']['cron'];
        $modules    = $locator->get( 'Zend\ModuleManager\ModuleManagerInterface' )
                              ->getModules();

        if ( ! in_array( 'Grid\MultisitePlatform', $modules ) ||
               in_array( 'Grid\MultisiteCentral',  $modules ) )
        {
            $keys[] = 'once';
        }

        foreach ( $keys as $key )
        {
            if ( ! empty( $cronConfig[$key][$type] ) )
            {
                foreach ( $cronConfig[$key][$type] as $service )
                {
                    if ( is_scalar( $service ) )
                    {
                        $service = array(
                            'service' => $service,
                        );
                    }

                    if ( ! empty( $service['service'] ) )
                    {
                        $return = call_user_func_array(
                            array(
                                $this->getServiceLocator()
                                     ->get( $service['service'] ),
                                empty( $service['method'] )
                                    ? '__invoke'
                                    : (string) $service['method']
                            ),
                            empty( $service['arguments'] )
                                ? array()
                                : (array) $service['arguments']
                        );

                        $result .= sprintf(
                            'Service "%s" / %s / %s ',
                            $service['service'],
                            $key,
                            $type
                        );

                        if ( ! empty( $service['method'] ) )
                        {
                            $result .= sprintf( 'called "%s" ', $service['method'] );
                        }

                        if ( ! empty( $service['arguments'] ) )
                        {
                            $result .= Debug::dump(
                                $service['arguments'],
                                'with',
                                false
                            );
                        }

                        $result .= Debug::dump( $return, 'returned', false );
                    }
                }
            }
        }

        return $result;
    }
240874
public function getIterator()
    {
        if ( null === $this->domainIterator )
        {
            /* @var $siteInfo \Zork\Db\SiteInfo */
            /* @var $moduleManager \Zend\ModuleManager\ModuleManagerInterface */
            $serviceLocator = $this->getServiceLocator();
            $siteInfo       = $serviceLocator->get( 'Zork\Db\SiteInfo' );
            $siteId         = $siteInfo->getSiteId();
            $moduleManager  = $serviceLocator->get(
                'Zend\ModuleManager\ModuleManagerInterface'
            );

            if ( $siteId && in_array( 'Grid\MultisitePlatform',
                                      $moduleManager->getModules() ) )
            {
                /* @var $domainModel \Grid\MultisitePlatform\Model\Domain\Model */
                $domains        = array();
                $domainModel    = $serviceLocator->get(
                    'Grid\MultisitePlatform\Model\Domain\Model'
                );

                foreach ( $domainModel->findAll( $siteId ) as $domain )
                {
                    if ( ! empty( $domain->domain ) )
                    {
                        $domains[] = $domain->domain;
                    }
                }
            }
            else
            {
                /* @var $dbAdapter \Zend\Db\Adapter\Adapter */
                $dbAdapter  = $serviceLocator->get( 'Zend\Db\Adapter\Adapter' );
                $config     = $dbAdapter->getDriver()
                                        ->getConnection()
                                        ->getConnectionParameters();

                if ( empty( $config['validDomains'] ) )
                {
                    $domains = array( 'localhost' );
                }
                else
                {
                    $domains = array_map(
                        'strtolower',
                        (array) $config['validDomains']
                    );
                }

                if ( ! empty( $config['defaultDomain'] ) )
                {
                    $defaultDomain = strtolower( $config['defaultDomain'] );

                    if ( ! in_array( $defaultDomain, $domains ) )
                    {
                        array_unshift( $domains, $defaultDomain );
                    }
                }
            }

            $domain = $siteInfo->getDomain();

            if ( ! in_array( $domain, $domains ) )
            {
                array_unshift( $domains, $domain );
            }

            $this->domainIterator = new ArrayIterator( $domains );
        }

        return $this->domainIterator;
    }
595926
function query() {
    ldap_servers_module_load_include('php', 'ldap_servers', 'LdapServer.class');
    $ldap_server = new LdapServer($this->sid);
    $ldap_server->connect();
    $ldap_server->bind();
    $results = array();

    $count = 0;

    foreach ($this->baseDn as $base_dn) {
      $result = $ldap_server->search($base_dn, $this->filter, $this->attributes, 0, $this->sizelimit, $this->timelimit, $this->deref, $this->scope);
      if ($result !== FALSE && $result['count'] > 0) {
        $count = $count + $result['count'];
        $results = array_merge($results, $result);
      }
    }
    $results['count'] = $count;

    return $results;
  }
632833
public function getDomain()
    {
        $returnValue = null;
        if (is_null($this->domain)){
        	$this->domain = new core_kernel_classes_ContainerCollection(new common_Object(__METHOD__));
			$domainValues = $this->getPropertyValues($this->getProperty(OntologyRdfs::RDFS_DOMAIN));
			foreach ($domainValues as $domainValue){
				$this->domain->add($this->getClass($domainValue));
			}
		}
		$returnValue = $this->domain;
        

        return $returnValue;
    }