Author: Adam Piotrowski (adam@wellcommerce.org)
コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function getResult(QueryBuilder $builder, DataSetRequestInterface $request, ColumnCollection $columns, CacheOptions $cache)
 {
     $total = $this->paginator->getTotalRows($builder, $columns);
     $result = parent::getResult($builder, $request, $columns, $cache);
     $filtered = $request->getConditions()->count() !== 0 ? count($result) : $total;
     return ['data_id' => $this->options['data_id'], 'rows_num' => $total, 'starting_from' => $request->getOffset(), 'total' => $total, 'filtered' => $total, 'rows' => $result];
 }
コード例 #2
0
 public function getPagination(QueryBuilder $queryBuilder, DataSetRequestInterface $request, ColumnCollection $columns)
 {
     $total = $this->dataSetPaginator->getTotalRows($queryBuilder, $columns);
     $offset = $request->getOffset();
     $limit = $request->getLimit();
     $currentPage = $offset / $limit + 1;
     $totalPages = ceil($total / $limit);
     return ['totalRows' => $total, 'currentPage' => $currentPage, 'totalPages' => ceil($total / $limit), 'currentResult' => ['rangeFrom' => $offset, 'rangeTo' => $this->calculateCurrentResultEnd($offset, $limit, $total)], 'nextPage' => $this->getNextPage($totalPages, $offset, $limit), 'previousPage' => $this->getPreviousPage($currentPage), 'pages' => $this->getPages($totalPages, $currentPage)];
 }