OpenSkill\Datatable\Providers\QueryBuilderProvider::process PHP Метод

process() публичный Метод

It will be called after {@link #prepareForProcessing} has been called and needs to return the processed data in a DTData object so the Composer can further handle the data.
public process ( ) : ResponseData
Результат OpenSkill\Datatable\Data\ResponseData The processed data
    public function process()
    {
        // check if the query configuration is set
        if (is_null($this->queryConfiguration) || empty($this->columnConfiguration)) {
            throw new \InvalidArgumentException("Provider was not configured. Did you call prepareForProcessing first?");
        }
        // limit
        $this->queryBeforeLimits = clone $this->query;
        $this->limitQuery();
        // # of items in filtered & ordered data set
        $dataCount = $this->queryBeforeLimits->count();
        // the data for the response
        $columns = $this->compileColumnNames();
        $response = new Collection($this->query->get($columns));
        // slice the result into the right size
        return new ResponseData($response, $this->getTotalNumberOfRows(), $dataCount);
    }

Usage Example

 private function orderAndSearchNotImplementedTest($searchableType = null)
 {
     $queryConfiguration = QueryConfigurationBuilder::create()->start(0)->length(4)->drawCall(1)->columnOrder('name', 'asc')->columnOrder('id', 'desc');
     $queryConfiguration = $queryConfiguration->searchValue('blah');
     $queryConfiguration = $queryConfiguration->build();
     $columnConfiguration = [];
     $columnConfiguration[] = ColumnConfigurationBuilder::create()->name('id')->searchable(Searchable::NONE())->build();
     $columnConfiguration[] = ColumnConfigurationBuilder::create()->name('name')->searchable($searchableType)->build();
     // Set up mock item
     $queryBuilder = $this->setupMockQueryBuilder();
     $provider = new QueryBuilderProvider($queryBuilder);
     $provider->prepareForProcessing($queryConfiguration, $columnConfiguration);
     $provider->process();
 }