From 8cbd800fb98514c477a7c18a7071db7b31f8a7d6 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 3 Jun 2025 14:50:58 +0200 Subject: [PATCH] Replace methods with injected services --- .../ChillMainBundle/CRUD/Controller/ApiController.php | 10 +++++----- .../Controller/AccompanyingCourseApiController.php | 10 +++++----- .../Controller/HouseholdApiController.php | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php b/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php index dcfe1aa0b..d09162820 100644 --- a/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php +++ b/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php @@ -154,7 +154,7 @@ class ApiController extends AbstractCRUDController return $response; } - $this->getManagerRegistry()->getManagerForClass($this->getEntityClass())->flush(); + $this->managerRegistry->getManagerForClass($this->getEntityClass())->flush(); $response = $this->onAfterFlush($action, $request, $_format, $entity, $errors); @@ -270,10 +270,10 @@ class ApiController extends AbstractCRUDController } if ($forcePersist && Request::METHOD_POST === $request->getMethod()) { - $this->getManagerRegistry()->getManager()->persist($postedData); + $this->managerRegistry->getManager()->persist($postedData); } - $this->getManagerRegistry()->getManager()->flush(); + $this->managerRegistry->getManager()->flush(); $response = $this->onAfterFlush($action, $request, $_format, $entity, $errors, [$postedData]); @@ -404,8 +404,8 @@ class ApiController extends AbstractCRUDController return $response; } - $this->getManagerRegistry()->getManager()->persist($entity); - $this->getManagerRegistry()->getManager()->flush(); + $this->managerRegistry->getManager()->persist($entity); + $this->managerRegistry->getManager()->flush(); $response = $this->onAfterFlush($action, $request, $_format, $entity, $errors); diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php index f575580b7..006aaa21b 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php @@ -105,7 +105,7 @@ final class AccompanyingCourseApiController extends ApiController if ($request->query->getBoolean('countOnly', false)) { return new JsonResponse( - $this->getSerializer()->serialize(new Counter($total), 'json'), + $this->serializer->serialize(new Counter($total), 'json'), JsonResponse::HTTP_OK, [], true @@ -116,7 +116,7 @@ final class AccompanyingCourseApiController extends ApiController if (0 === $total) { return new JsonResponse( - $this->getSerializer()->serialize(new Collection([], $paginator), 'json'), + $this->serializer->serialize(new Collection([], $paginator), 'json'), JsonResponse::HTTP_OK, [], true @@ -131,7 +131,7 @@ final class AccompanyingCourseApiController extends ApiController ); return new JsonResponse( - $this->getSerializer()->serialize(new Collection($courses, $paginator), 'json', ['groups' => ['read']]), + $this->serializer->serialize(new Collection($courses, $paginator), 'json', ['groups' => ['read']]), JsonResponse::HTTP_OK, [], true @@ -156,7 +156,7 @@ final class AccompanyingCourseApiController extends ApiController { /** @var AccompanyingPeriod $accompanyingPeriod */ $accompanyingPeriod = $this->getEntity('participation', $id, $request); - $person = $this->getSerializer() + $person = $this->serializer ->deserialize($request->getContent(), Person::class, $_format, []); if (null === $person) { @@ -202,7 +202,7 @@ final class AccompanyingCourseApiController extends ApiController $exceptions = []; try { - $requestor = $this->getSerializer()->deserialize( + $requestor = $this->serializer->deserialize( $request->getContent(), '@multi', $_format, diff --git a/src/Bundle/ChillPersonBundle/Controller/HouseholdApiController.php b/src/Bundle/ChillPersonBundle/Controller/HouseholdApiController.php index 872dc0e5c..8499aa2b3 100644 --- a/src/Bundle/ChillPersonBundle/Controller/HouseholdApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/HouseholdApiController.php @@ -71,7 +71,7 @@ class HouseholdApiController extends ApiController $this->denyAccessUnlessGranted(HouseholdVoter::EDIT, $household); /** @var Address $address */ - $address = $this->getSerializer()->deserialize($request->getContent(), Address::class, $_format, [ + $address = $this->serializer->deserialize($request->getContent(), Address::class, $_format, [ AbstractNormalizer::GROUPS => ['write'], ]);