/** * Fetch and return all results of this query * * @return array */ public function fetchAll() { if (!$this->hasOrder()) { $this->order(); } $results = $this->query->fetchAll(); if (!empty($results) && $this->repository->providesValueConversion($this->target)) { $updateOrder = false; $columns = $this->getColumns(); $flippedColumns = array_flip($columns); foreach ($results as $row) { foreach ($columns as $alias => $column) { if (!is_string($alias)) { $alias = $column; } $row->{$alias} = $this->repository->retrieveColumn($this->target, $this->getNativeAlias($alias), $row->{$alias}, $this); } foreach ($this->getOrder() ?: array() as $rule) { $nativeAlias = $this->getNativeAlias($rule[0]); if (!array_key_exists($rule[0], $flippedColumns) && property_exists($row, $rule[0])) { if ($this->repository->providesValueConversion($this->target, $nativeAlias)) { $updateOrder = true; $row->{$rule[0]} = $this->repository->retrieveColumn($this->target, $nativeAlias, $row->{$rule[0]}, $this); } } elseif (array_key_exists($rule[0], $flippedColumns)) { if ($this->repository->providesValueConversion($this->target, $nativeAlias)) { $updateOrder = true; } } } } if ($updateOrder) { uasort($results, array($this->query, 'compare')); } } return $results; }