yii\sphinx\ActiveDataProvider::prepareModels PHP Метод

prepareModels() защищенный Метод

protected prepareModels ( )
    protected function prepareModels()
    {
        if (!$this->query instanceof Query) {
            throw new InvalidConfigException('The "query" property must be an instance "' . Query::className() . '" or its subclasses.');
        }
        $query = clone $this->query;
        if (($pagination = $this->getPagination()) !== false) {
            if (empty($query->showMeta)) {
                $pagination->totalCount = $this->getTotalCount();
                $limit = $pagination->getLimit();
                $offset = $pagination->getOffset();
                // pagination may exceed 'max_matches' boundary producing query error
                if (!isset($query->options['max_matches'])) {
                    $query->options['max_matches'] = $offset + $limit;
                }
                $query->limit($limit)->offset($offset);
            } else {
                // pagination fails to validate page number, if total count is unknown at this stage
                $pagination->validatePage = false;
                $query->limit($pagination->getLimit())->offset($pagination->getOffset());
            }
        }
        if (($sort = $this->getSort()) !== false) {
            $query->addOrderBy($sort->getOrders());
        }
        $results = $query->search($this->db);
        $this->setMeta($results['meta']);
        $this->setFacets($results['facets']);
        if ($pagination !== false) {
            $pagination->totalCount = $this->getTotalCount();
        }
        return $results['hits'];
    }