From 368df2b78628d7a8ef5d92327540a892590f4233 Mon Sep 17 00:00:00 2001 From: Akex Date: Mon, 8 Apr 2024 23:29:22 +0500 Subject: [PATCH 1/6] make prepareMenu --- src/Controller/PrepareMenuController.php | 22 +++++++++++++++++++ src/Repository/PrepareMenuRepository.php | 27 ++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 src/Controller/PrepareMenuController.php create mode 100644 src/Repository/PrepareMenuRepository.php diff --git a/src/Controller/PrepareMenuController.php b/src/Controller/PrepareMenuController.php new file mode 100644 index 0000000..8f6cfca --- /dev/null +++ b/src/Controller/PrepareMenuController.php @@ -0,0 +1,22 @@ +toArray(); + + $return = prepareMenu($array); + + return new JsonResponse($return, Response::HTTP_OK); + } +} diff --git a/src/Repository/PrepareMenuRepository.php b/src/Repository/PrepareMenuRepository.php new file mode 100644 index 0000000..ee842c4 --- /dev/null +++ b/src/Repository/PrepareMenuRepository.php @@ -0,0 +1,27 @@ + Date: Mon, 8 Apr 2024 23:32:03 +0500 Subject: [PATCH 2/6] fix repo dependency --- src/Controller/PrepareMenuController.php | 1 + src/Repository/PrepareMenuRepository.php | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/Controller/PrepareMenuController.php b/src/Controller/PrepareMenuController.php index 8f6cfca..96ab597 100644 --- a/src/Controller/PrepareMenuController.php +++ b/src/Controller/PrepareMenuController.php @@ -7,6 +7,7 @@ use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; +use function App\Repository\prepareMenu; class PrepareMenuController extends AbstractController { diff --git a/src/Repository/PrepareMenuRepository.php b/src/Repository/PrepareMenuRepository.php index ee842c4..e1be3c7 100644 --- a/src/Repository/PrepareMenuRepository.php +++ b/src/Repository/PrepareMenuRepository.php @@ -1,4 +1,6 @@ Date: Tue, 9 Apr 2024 00:06:04 +0500 Subject: [PATCH 3/6] fix controller --- src/Controller/PrepareMenuController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controller/PrepareMenuController.php b/src/Controller/PrepareMenuController.php index 96ab597..8e19daf 100644 --- a/src/Controller/PrepareMenuController.php +++ b/src/Controller/PrepareMenuController.php @@ -11,7 +11,7 @@ use function App\Repository\prepareMenu; class PrepareMenuController extends AbstractController { - #[Route('/prepare/menu', name: 'app_prepare_menu')] + #[Route('/prepare/menu', name: 'app_prepare_menu', methods: ['POST'])] public function index(Request $request): Response { $array = $request->toArray(); -- GitLab From 1f3660368d25da08d9798cc305206db751d08c62 Mon Sep 17 00:00:00 2001 From: Akex Date: Tue, 9 Apr 2024 00:38:09 +0500 Subject: [PATCH 4/6] add phpDoc --- src/Controller/PrepareMenuController.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Controller/PrepareMenuController.php b/src/Controller/PrepareMenuController.php index 8e19daf..fb46687 100644 --- a/src/Controller/PrepareMenuController.php +++ b/src/Controller/PrepareMenuController.php @@ -11,6 +11,12 @@ use function App\Repository\prepareMenu; class PrepareMenuController extends AbstractController { + /** + * Контроллер реструктурирует массив меню добавляя вложенность по значению depth + * используюя prepareMenu функцию + * @param Request $request + * @return Response + */ #[Route('/prepare/menu', name: 'app_prepare_menu', methods: ['POST'])] public function index(Request $request): Response { -- GitLab From 2937ba8b95a874da32d3e424533e4a2ba9f3c613 Mon Sep 17 00:00:00 2001 From: "Alex. Plokhikh" Date: Mon, 15 Apr 2024 16:52:39 +0500 Subject: [PATCH 5/6] create controller and action menu prepare and req --- src/Actions/PrepareMenuAction.php | 35 ++++++++++++++++++++++++ src/Controller/PrepareMenuController.php | 18 ++++++------ src/Repository/PrepareMenuRepository.php | 29 -------------------- src/Requests/MenuRequest.php | 32 ++++++++++++++++++++++ 4 files changed, 76 insertions(+), 38 deletions(-) create mode 100644 src/Actions/PrepareMenuAction.php delete mode 100644 src/Repository/PrepareMenuRepository.php create mode 100644 src/Requests/MenuRequest.php diff --git a/src/Actions/PrepareMenuAction.php b/src/Actions/PrepareMenuAction.php new file mode 100644 index 0000000..6c81983 --- /dev/null +++ b/src/Actions/PrepareMenuAction.php @@ -0,0 +1,35 @@ +toArray(); - - $return = prepareMenu($array); - - return new JsonResponse($return, Response::HTTP_OK); + return new JsonResponse( + $action->act($request->serialise()), + 200 + ); } } diff --git a/src/Repository/PrepareMenuRepository.php b/src/Repository/PrepareMenuRepository.php deleted file mode 100644 index e1be3c7..0000000 --- a/src/Repository/PrepareMenuRepository.php +++ /dev/null @@ -1,29 +0,0 @@ - [ + new NotBlank(), + new Type('string'), + ], + 'depth' => [ + new NotBlank(), + new Type('integer'), + ] + ]) + )] + public $menu; + + public function serialise(): mixed + { + return $this->menu; + } +} -- GitLab From 1af58e1ce6a77cd68007a508e682a9f39921e3cc Mon Sep 17 00:00:00 2001 From: "Alex. Plokhikh" Date: Tue, 16 Apr 2024 01:51:12 +0500 Subject: [PATCH 6/6] rm 200 status --- src/Controller/PrepareMenuController.php | 5 +---- src/Controller/SortPriceController.php | 10 ++-------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/Controller/PrepareMenuController.php b/src/Controller/PrepareMenuController.php index 1e3334f..49a74dd 100644 --- a/src/Controller/PrepareMenuController.php +++ b/src/Controller/PrepareMenuController.php @@ -21,9 +21,6 @@ class PrepareMenuController extends AbstractController #[Route('/prepare/menu', name: 'app_prepare_menu', methods: ['POST'])] public function index(MenuRequest $request, PrepareMenuAction $action): Response { - return new JsonResponse( - $action->act($request->serialise()), - 200 - ); + return new JsonResponse($action->act($request->serialise())); } } diff --git a/src/Controller/SortPriceController.php b/src/Controller/SortPriceController.php index 313d3dc..0f1d250 100644 --- a/src/Controller/SortPriceController.php +++ b/src/Controller/SortPriceController.php @@ -3,28 +3,22 @@ namespace App\Controller; use App\Actions\SortPriceAction; -use App\Entity\PricesEntity; use App\Requests\PricesRequest; -use App\Service\ValidationService; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\JsonResponse; -use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Attribute\Route; class SortPriceController extends AbstractController { /** * Контроллер волняет сортировку массива по убыванию цены используя sortPrice - * @param Request $request + * @param PricesRequest $request * @param SortPriceAction $action * @return JsonResponse */ #[Route('/sort/price', name: 'app_sort_price', methods: ['POST'])] public function index(PricesRequest $request, SortPriceAction $action): JsonResponse { - return new JsonResponse( - $action->act($request->serialise()), - 200 - ); + return new JsonResponse($action->act($request->serialise())); } } -- GitLab