From 693a2889bcf5a736cca49ef92e4875ade3547bd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 22 Oct 2021 17:24:05 +0200 Subject: [PATCH 1/2] fix query customization in crud controller --- .../ChillMainBundle/CRUD/Controller/CRUDController.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php b/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php index 9c657ae46..d3112fd97 100644 --- a/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php +++ b/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php @@ -342,13 +342,19 @@ class CRUDController extends AbstractController */ protected function buildQueryEntities(string $action, Request $request) { - return $this->getDoctrine()->getManager() + $query = $this->getDoctrine()->getManager() ->createQueryBuilder() ->select('e') ->from($this->getEntityClass(), 'e') ; + + $this->customizeQuery($action, $request, $query); + + return $query; } + protected function customizeQuery(string $action, Request $request, $query): void {} + /** * Query the entity. * From 4d55b0582cbcfd09809c923dea09abd68f1e9871 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 22 Oct 2021 17:25:54 +0200 Subject: [PATCH 2/2] change visibility of methods in LocationCotnroller --- .../ChillMainBundle/Controller/LocationController.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Controller/LocationController.php b/src/Bundle/ChillMainBundle/Controller/LocationController.php index e6aba8fc3..dc59db9b1 100644 --- a/src/Bundle/ChillMainBundle/Controller/LocationController.php +++ b/src/Bundle/ChillMainBundle/Controller/LocationController.php @@ -7,14 +7,14 @@ use Symfony\Component\HttpFoundation\Request; class LocationController extends CRUDController { - public function customizeQuery(string $action, Request $request, $query): void + protected function customizeQuery(string $action, Request $request, $query): void { //$query->where('e.availableforusers', "'TRUE'"); // not working $query->where('e.availableForUsers = true'); //TODO not working } - - public function createEntity(string $action, Request $request): object + + protected function createEntity(string $action, Request $request): object { $entity = parent::createEntity($action, $request); @@ -22,4 +22,4 @@ class LocationController extends CRUDController return $entity; } -} \ No newline at end of file +}