Esempio n. 1
0
 /**
  * Paginated resultset in ext direct format
  *
  * @param Query $query
  *
  * @return array data in ext direct format
  */
 public function toArray()
 {
     if ($this->params->has('sort')) {
         $this->addSort();
     }
     $this->limit = $this->params->getInt('limit', 10);
     $this->start = $this->params->getInt('start', 0);
     if ($this->params->has('page') && $this->params->get('page') > 0) {
         $offset = ($this->params->get('page') - 1) * $this->limit;
     } else {
         $offset = 0;
     }
     $query = $this->qb->getQuery();
     if ($this->limit != 0) {
         $this->count = Paginate::getTotalQueryResults($query);
         $paginateQuery = Paginate::getPaginateQuery($query, $offset, $this->limit);
         $this->entities = $paginateQuery->getResult();
     } else {
         $this->entities = $query->getResult();
         $this->count = count($this->entities);
     }
     return $this->dumper->dump($this)->toArray();
 }