From d62df73cc46322c1fcacfc18e4800f61d1cc3156 Mon Sep 17 00:00:00 2001 From: Akex Date: Mon, 8 Apr 2024 23:19:14 +0500 Subject: [PATCH 1/5] make UniqFilter --- src/Controller/UniqElementsController.php | 23 ++++++++++++++++++ src/Repository/UniqElementsRepository.php | 29 +++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 src/Controller/UniqElementsController.php create mode 100644 src/Repository/UniqElementsRepository.php diff --git a/src/Controller/UniqElementsController.php b/src/Controller/UniqElementsController.php new file mode 100644 index 0000000..52161bc --- /dev/null +++ b/src/Controller/UniqElementsController.php @@ -0,0 +1,23 @@ +toArray(); + + $return = uniqElements($requestArray); + + return new JsonResponse($return, Response::HTTP_OK); + } +} diff --git a/src/Repository/UniqElementsRepository.php b/src/Repository/UniqElementsRepository.php new file mode 100644 index 0000000..27b3d65 --- /dev/null +++ b/src/Repository/UniqElementsRepository.php @@ -0,0 +1,29 @@ + $item){ + $item = array_unique($item); + foreach ($item as $oneOfItem){ + $returnableArray[] = [ + $key, + $oneOfItem + ]; + } + } + + return $returnableArray; +} -- GitLab From 258321e3f2547249ee4b4980b7b04cb9f4ec2f99 Mon Sep 17 00:00:00 2001 From: Akex Date: Tue, 9 Apr 2024 00:35:14 +0500 Subject: [PATCH 2/5] add phpDoc --- src/Controller/UniqElementsController.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Controller/UniqElementsController.php b/src/Controller/UniqElementsController.php index 52161bc..ff46b93 100644 --- a/src/Controller/UniqElementsController.php +++ b/src/Controller/UniqElementsController.php @@ -11,6 +11,11 @@ use function App\Repository\uniqElements; class UniqElementsController extends AbstractController { + /** + * Контроллер удаляет дубликаты, оставив только уникальные значения используя uniqElements функцию + * @param Request $request + * @return Response + */ #[Route('/uniq/elements', name: 'app_uniq_elements')] public function index(Request $request): Response { -- GitLab From 782349637780d9a445223fccaa1b0e518a86bb1c Mon Sep 17 00:00:00 2001 From: "Alex. Plokhikh" Date: Mon, 15 Apr 2024 16:24:25 +0500 Subject: [PATCH 3/5] create filtrer controller and action and req --- src/Actions/UniqElementsAction.php | 16 +++++++++++++ src/Controller/UniqElementsController.php | 22 +++++++---------- src/Repository/UniqElementsRepository.php | 29 ----------------------- src/Requests/UniqElementsRequest.php | 21 ++++++++++++++++ templates/uniq_elements/index.html.twig | 20 ++++++++++++++++ 5 files changed, 65 insertions(+), 43 deletions(-) create mode 100644 src/Actions/UniqElementsAction.php delete mode 100644 src/Repository/UniqElementsRepository.php create mode 100644 src/Requests/UniqElementsRequest.php create mode 100644 templates/uniq_elements/index.html.twig diff --git a/src/Actions/UniqElementsAction.php b/src/Actions/UniqElementsAction.php new file mode 100644 index 0000000..3aa0e13 --- /dev/null +++ b/src/Actions/UniqElementsAction.php @@ -0,0 +1,16 @@ +toArray(); - - $return = uniqElements($requestArray); - - return new JsonResponse($return, Response::HTTP_OK); + return new JsonResponse( + $action->act($request->serialise()), + 200 + ); } } diff --git a/src/Repository/UniqElementsRepository.php b/src/Repository/UniqElementsRepository.php deleted file mode 100644 index 27b3d65..0000000 --- a/src/Repository/UniqElementsRepository.php +++ /dev/null @@ -1,29 +0,0 @@ - $item){ - $item = array_unique($item); - foreach ($item as $oneOfItem){ - $returnableArray[] = [ - $key, - $oneOfItem - ]; - } - } - - return $returnableArray; -} diff --git a/src/Requests/UniqElementsRequest.php b/src/Requests/UniqElementsRequest.php new file mode 100644 index 0000000..1117313 --- /dev/null +++ b/src/Requests/UniqElementsRequest.php @@ -0,0 +1,21 @@ +data; + } +} diff --git a/templates/uniq_elements/index.html.twig b/templates/uniq_elements/index.html.twig new file mode 100644 index 0000000..d56494b --- /dev/null +++ b/templates/uniq_elements/index.html.twig @@ -0,0 +1,20 @@ +{% extends 'base.html.twig' %} + +{% block title %}Hello UniqElementsController!{% endblock %} + +{% block body %} + + +
+

Hello {{ controller_name }}! ✅

+ + This friendly message is coming from: +
    +
  • Your controller at /home/tamanit/myProj/iqdevTranningProgram/src/Controller/UniqElementsController.php
  • +
  • Your template at /home/tamanit/myProj/iqdevTranningProgram/templates/uniq_elements/index.html.twig
  • +
+
+{% endblock %} -- GitLab From 9c2ecedc4a6d59ff2f21256ba0a5d3d3aa8f3721 Mon Sep 17 00:00:00 2001 From: "Alex. Plokhikh" Date: Tue, 16 Apr 2024 01:18:43 +0500 Subject: [PATCH 4/5] rm 200 status init in resp --- src/Controller/SortPriceController.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) 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 From b502dc154d337c732d47265c26c51f9793768f51 Mon Sep 17 00:00:00 2001 From: "Alex. Plokhikh" Date: Tue, 16 Apr 2024 01:42:54 +0500 Subject: [PATCH 5/5] rm another 200 status --- src/Controller/UniqElementsController.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Controller/UniqElementsController.php b/src/Controller/UniqElementsController.php index 6652b9d..442c9d7 100644 --- a/src/Controller/UniqElementsController.php +++ b/src/Controller/UniqElementsController.php @@ -14,9 +14,6 @@ class UniqElementsController extends AbstractController #[Route('/uniq/elements', name: 'app_uniq_elements', methods: ['POST'])] public function index(UniqElementsRequest $request, UniqElementsAction $action): Response { - return new JsonResponse( - $action->act($request->serialise()), - 200 - ); + return new JsonResponse($action->act($request->serialise())); } } -- GitLab