From 0131287ae56827bdc74d76b0114aa343b515631a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9becca=20Tinchon?= Date: Tue, 3 Sep 2024 14:03:59 +0200 Subject: [PATCH] pr review 2 --- .../cursus/Controller/CourseController.php | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/plugin/cursus/Controller/CourseController.php b/src/plugin/cursus/Controller/CourseController.php index 4325387094..be30ba59c7 100644 --- a/src/plugin/cursus/Controller/CourseController.php +++ b/src/plugin/cursus/Controller/CourseController.php @@ -104,6 +104,8 @@ protected function getDefaultHiddenFilters(): array if (!$this->checkToolAccess('EDIT')) { $filters['hidden'] = false; } + + $filters['archived'] = false; } return $filters; @@ -115,9 +117,7 @@ protected function getDefaultHiddenFilters(): array public function listAction(Request $request): JsonResponse { $params = $request->query->all(); - $params['hiddenFilters'] = [ - 'archived' => false, - ]; + $params['hiddenFilters'] = array_merge($this->getDefaultHiddenFilters(), $params['hiddenFilters'] ?? []); return new JsonResponse( $this->crud->list(Course::class, $params) @@ -129,16 +129,16 @@ public function listAction(Request $request): JsonResponse */ public function listPublicAction(Request $request): JsonResponse { - $params = $request->query->all(); - $params['hiddenFilters'] = [ - 'public' => true, - ]; - - return new JsonResponse( - $this->crud->list(Course::class, $params) - ); + return new JsonResponse($this->crud->list( + Course::class, + array_merge($request->query->all(), ['hiddenFilters' => array_merge($this->getDefaultHiddenFilters(), [ + 'public' => true, + ])]), + $this->getOptions()['list'] + )); } + /** * @Route("/list/archived", name="apiv2_cursus_course_list_archived", methods={"GET"}) */