diff --git a/src/Bundle/ChillMainBundle/Controller/GenderApiController.php b/src/Bundle/ChillMainBundle/Controller/GenderApiController.php index fd47afb85..96fae4024 100644 --- a/src/Bundle/ChillMainBundle/Controller/GenderApiController.php +++ b/src/Bundle/ChillMainBundle/Controller/GenderApiController.php @@ -17,6 +17,14 @@ use Symfony\Component\HttpFoundation\Request; class GenderApiController extends ApiController { + protected function customizeQuery(string $action, Request $request, $query): void + { + $query + ->andWhere( + $query->expr()->eq('e.active', "'TRUE'") + ); + } + protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator, $_format) { return $query->addOrderBy('e.order', 'ASC'); diff --git a/src/Bundle/ChillMainBundle/Repository/GenderRepository.php b/src/Bundle/ChillMainBundle/Repository/GenderRepository.php index e70454ba9..d446dbcca 100644 --- a/src/Bundle/ChillMainBundle/Repository/GenderRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/GenderRepository.php @@ -24,4 +24,14 @@ class GenderRepository extends ServiceEntityRepository { parent::__construct($registry, Gender::class); } + + public function findByActiveOrdered(): array + { + return $this->createQueryBuilder('g') + ->select('g') + ->where('g.active = True') + ->orderBy('g.order', 'ASC') + ->getQuery() + ->getResult(); + } }