From 692c2bdac0c14b746aec1aa4a3f3f57b00ac7d53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 11 Jul 2022 16:11:45 +0200 Subject: [PATCH] fixed: do not show disabled users in list of users from the api --- .../ChillMainBundle/Controller/UserApiController.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Bundle/ChillMainBundle/Controller/UserApiController.php b/src/Bundle/ChillMainBundle/Controller/UserApiController.php index d1fd4d5bb..6acd0c4dd 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserApiController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserApiController.php @@ -12,7 +12,9 @@ declare(strict_types=1); namespace Chill\MainBundle\Controller; use Chill\MainBundle\CRUD\Controller\ApiController; +use Doctrine\ORM\QueryBuilder; use Symfony\Component\HttpFoundation\JsonResponse; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Annotation\Route; class UserApiController extends ApiController @@ -58,4 +60,14 @@ class UserApiController extends ApiController ['groups' => ['read']] ); } + + /** + * @param QueryBuilder $query + */ + protected function customizeQuery(string $action, Request $request, $query): void + { + if ('_index' === $action) { + $query->andWhere($query->expr()->eq('e.enabled', "'TRUE'")); + } + } }