Ejemplo n.º 1
0
 /**
  * It is possible to use query builder with additional columns.
  * In this case, only item at index [0] is returned, because
  * it should be an entity object.
  * @return array
  */
 public function getData()
 {
     // Paginator is better if the query uses ManyToMany associations
     $usePaginator = $this->qb->getMaxResults() !== NULL || $this->qb->getFirstResult() !== NULL;
     $data = array();
     if ($usePaginator) {
         $paginator = new Paginator($this->getQuery());
         // Convert paginator to the array
         foreach ($paginator as $result) {
             // Return only entity itself
             $data[] = is_array($result) ? $result[0] : $result;
         }
     } else {
         foreach ($this->qb->getQuery()->getResult() as $result) {
             // Return only entity itself
             $data[] = is_array($result) ? $result[0] : $result;
         }
     }
     return $data;
 }