/** * Finds all documents satisfying the specified condition. * See {@link find()} for detailed explanation about $condition and $params. * * @param array|CriteriaInterface $criteria query criteria. * @return AnnotatedInterface[]|Cursor */ public function findAll($criteria = null) { if ($this->_beforeFind()) { $criteria = $this->sm->apply($criteria); $criteria->decorateWith($this->model); $cursor = $this->em->getCollection()->find($criteria->getConditions()); if ($criteria->getSort() !== null) { $cursor->sort($criteria->getSort()); } if ($criteria->getLimit() !== null) { $cursor->limit($criteria->getLimit()); } if ($criteria->getOffset() !== null) { $cursor->skip($criteria->getOffset()); } if ($criteria->getSelect()) { $cursor->fields($criteria->getSelect()); } $this->mn->getProfiler()->cursor($cursor); if ($this->_useCursor) { return new Cursor($cursor, $this->model); } else { return $this->populateRecords($cursor); } } return []; }