OpenSkill\Datatable\Providers\QueryBuilderProvider::prepareForProcessing PHP Method

prepareForProcessing() public method

This will only be called when the DTProvider needs to handle the request. It will never be called when the DTProvider does not need to handle the request.
public prepareForProcessing ( OpenSkill\Datatable\Queries\QueryConfiguration $queryConfiguration, array $columnConfiguration ) : mixed
$queryConfiguration OpenSkill\Datatable\Queries\QueryConfiguration
$columnConfiguration array
return mixed
    public function prepareForProcessing(QueryConfiguration $queryConfiguration, array $columnConfiguration)
    {
        $this->queryConfiguration = $queryConfiguration;
        $this->columnConfiguration = $columnConfiguration;
        // compile the query first
        $this->compileQuery();
        // sort
        $this->sortQuery();
    }

Usage Example

 /**
  * @expectedException OpenSkill\Datatable\DatatableException
  * @expectedExceptionMessage A requested column was not found in the columnConfiguration.
  */
 public function testExceptionIfColumnIsNotFound()
 {
     $queryConfiguration = QueryConfigurationBuilder::create()->start(0)->length(2)->drawCall(1)->columnOrder('name', 'desc')->build();
     $columnConfiguration = ColumnConfigurationBuilder::create()->name('foundColumn')->build();
     /**
      * Create a mocked query builder...
      */
     $queryBuilder = $this->setupMockQueryBuilder();
     $queryBuilder->shouldReceive('orderBy')->with('name', 'desc')->once();
     $queryBuilder->shouldReceive('skip')->with(0);
     $queryBuilder->shouldReceive('limit')->with(2);
     $queryBuilder->shouldReceive('count')->withNoArgs();
     $queryBuilder->shouldReceive('get')->withArgs([['name']]);
     $provider = new QueryBuilderProvider($queryBuilder);
     $provider->prepareForProcessing($queryConfiguration, [$columnConfiguration]);
     $getColumnFromName = new \ReflectionMethod($provider, 'getColumnFromName');
     $getColumnFromName->setAccessible(true);
     //$provider->getColumnFromName('notFound');
     $getColumnFromName->invoke($provider, 'notFound');
 }
All Usage Examples Of OpenSkill\Datatable\Providers\QueryBuilderProvider::prepareForProcessing