/** * @param GetOrganizationListRequest $request * * @return Criteria */ private function buildCriteria($request) { $criteria = new Criteria(); $field = new OrganizationField(OrganizationField::NAME); $fieldFilter = new FieldFilter($field, FieldFilter::OPERATION_LIKE, '%' . $request->organizationName() . '%'); return $criteria->addFieldFilter($fieldFilter)->setPage($request->page()); }
/** * @param Criteria $criteria * * @return EntityRepositoryResult */ public function findByCriteria(Criteria $criteria) { return new EntityRepositoryResult($this->entities, $criteria->page(), count($this->entities), $criteria->rowsPerPage(), ceil(count($this->entities) / $criteria->rowsPerPage())); }
/** * @param Paginator $paginator * @param Criteria $criteria * * @return mixed */ private function getPageResult(Paginator $paginator, Criteria $criteria) { return $paginator->getQuery()->setFirstResult($criteria->rowsPerPage() * ($criteria->page() - 1))->setMaxResults($criteria->rowsPerPage())->getResult(); }