/**
  * Is responsible to take the generated data and prepare a response for it.
  * @param ResponseData $data The processed data.
  * @param QueryConfiguration $queryConfiguration the query configuration for the current request.
  * @param array $columnConfiguration the column configurations for the current data table.
  * @return JsonResponse the response that should be returned to the client.
  */
 public function createResponse(ResponseData $data, QueryConfiguration $queryConfiguration, array $columnConfiguration)
 {
     // TODO: Implement createResponse() method.
     // will generate the response according to: http://legacy.datatables.net/usage/server-side
     $responseData = ['sEcho' => $queryConfiguration->drawCall(), 'iTotalRecords' => $data->totalDataCount(), 'iTotalDisplayRecords' => $data->data()->count(), 'aaData' => $data->data()->toArray()];
     return new JsonResponse($responseData);
 }
 /**
  * Will sort the internal collection based on the given query configuration.
  * Most tables only support the ordering by just one column, but we will enable sorting on all columns here
  */
 private function sortCollection()
 {
     if ($this->queryConfiguration->hasOrderColumn()) {
         $order = $this->queryConfiguration->orderColumns();
         $orderFunc = $this->defaultGlobalOrderFunction;
         $this->collection = $this->collection->sort(function ($first, $second) use($order, $orderFunc) {
             return $orderFunc($first, $second, $order);
         });
     }
 }
 /**
  * Will sort the internal collection based on the given query configuration.
  * All tables only support the ordering by just one column, so if there is ordering just take the first ordering
  */
 private function sortCollection()
 {
     if ($this->queryConfiguration->hasOrderColumn()) {
         $order = $this->queryConfiguration->orderColumns()[0];
         $this->collection->sort(function ($first, $second) use($order) {
             return strnatcmp($first[$order->columnName()], $second[$order->columnName()]);
         });
         if (!$order->isAscending()) {
             $this->collection->reverse();
         }
     }
 }
 /**
  * Is responsible to take the generated data and prepare a response for it.
  * @param ResponseData $data The processed data.
  * @param QueryConfiguration $queryConfiguration the query configuration for the current request.
  * @param ColumnConfiguration[] $columnConfigurations the column configurations for the current data table.
  * @return JsonResponse the response that should be returned to the client.
  */
 public function createResponse(ResponseData $data, QueryConfiguration $queryConfiguration, array $columnConfigurations)
 {
     $responseData = ['sEcho' => $queryConfiguration->drawCall(), 'iTotalRecords' => $data->totalDataCount(), 'iTotalDisplayRecords' => $data->filteredDataCount(), 'aaData' => $data->data()->toArray()];
     return new JsonResponse($responseData);
 }
 /**
  * Is responsible to take the generated data and prepare a response for it.
  * @param ResponseData $data The processed data.
  * @param QueryConfiguration $queryConfiguration the query configuration for the current request.
  * @param ColumnConfiguration[] $columnConfigurations the column configurations for the current data table.
  * @return JsonResponse the response that should be returned to the client.
  */
 public function createResponse(ResponseData $data, QueryConfiguration $queryConfiguration, array $columnConfigurations)
 {
     $responseData = ['draw' => $queryConfiguration->drawCall(), 'recordsTotal' => $data->totalDataCount(), 'recordsFiltered' => $data->filteredDataCount(), 'data' => $data->data()->toArray()];
     return new JsonResponse($responseData);
 }
 /**
  * Will limit a query based on the start and length given
  */
 private function limitQuery()
 {
     $this->query->skip($this->queryConfiguration->start());
     $this->query->limit($this->queryConfiguration->length());
 }