Replace methods with injected services

This commit is contained in:
Julie Lenaerts 2025-06-03 14:50:58 +02:00
parent 1f79985193
commit 8cbd800fb9
3 changed files with 11 additions and 11 deletions

View File

@ -154,7 +154,7 @@ class ApiController extends AbstractCRUDController
return $response; return $response;
} }
$this->getManagerRegistry()->getManagerForClass($this->getEntityClass())->flush(); $this->managerRegistry->getManagerForClass($this->getEntityClass())->flush();
$response = $this->onAfterFlush($action, $request, $_format, $entity, $errors); $response = $this->onAfterFlush($action, $request, $_format, $entity, $errors);
@ -270,10 +270,10 @@ class ApiController extends AbstractCRUDController
} }
if ($forcePersist && Request::METHOD_POST === $request->getMethod()) { 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]); $response = $this->onAfterFlush($action, $request, $_format, $entity, $errors, [$postedData]);
@ -404,8 +404,8 @@ class ApiController extends AbstractCRUDController
return $response; return $response;
} }
$this->getManagerRegistry()->getManager()->persist($entity); $this->managerRegistry->getManager()->persist($entity);
$this->getManagerRegistry()->getManager()->flush(); $this->managerRegistry->getManager()->flush();
$response = $this->onAfterFlush($action, $request, $_format, $entity, $errors); $response = $this->onAfterFlush($action, $request, $_format, $entity, $errors);

View File

@ -105,7 +105,7 @@ final class AccompanyingCourseApiController extends ApiController
if ($request->query->getBoolean('countOnly', false)) { if ($request->query->getBoolean('countOnly', false)) {
return new JsonResponse( return new JsonResponse(
$this->getSerializer()->serialize(new Counter($total), 'json'), $this->serializer->serialize(new Counter($total), 'json'),
JsonResponse::HTTP_OK, JsonResponse::HTTP_OK,
[], [],
true true
@ -116,7 +116,7 @@ final class AccompanyingCourseApiController extends ApiController
if (0 === $total) { if (0 === $total) {
return new JsonResponse( return new JsonResponse(
$this->getSerializer()->serialize(new Collection([], $paginator), 'json'), $this->serializer->serialize(new Collection([], $paginator), 'json'),
JsonResponse::HTTP_OK, JsonResponse::HTTP_OK,
[], [],
true true
@ -131,7 +131,7 @@ final class AccompanyingCourseApiController extends ApiController
); );
return new JsonResponse( 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, JsonResponse::HTTP_OK,
[], [],
true true
@ -156,7 +156,7 @@ final class AccompanyingCourseApiController extends ApiController
{ {
/** @var AccompanyingPeriod $accompanyingPeriod */ /** @var AccompanyingPeriod $accompanyingPeriod */
$accompanyingPeriod = $this->getEntity('participation', $id, $request); $accompanyingPeriod = $this->getEntity('participation', $id, $request);
$person = $this->getSerializer() $person = $this->serializer
->deserialize($request->getContent(), Person::class, $_format, []); ->deserialize($request->getContent(), Person::class, $_format, []);
if (null === $person) { if (null === $person) {
@ -202,7 +202,7 @@ final class AccompanyingCourseApiController extends ApiController
$exceptions = []; $exceptions = [];
try { try {
$requestor = $this->getSerializer()->deserialize( $requestor = $this->serializer->deserialize(
$request->getContent(), $request->getContent(),
'@multi', '@multi',
$_format, $_format,

View File

@ -71,7 +71,7 @@ class HouseholdApiController extends ApiController
$this->denyAccessUnlessGranted(HouseholdVoter::EDIT, $household); $this->denyAccessUnlessGranted(HouseholdVoter::EDIT, $household);
/** @var Address $address */ /** @var Address $address */
$address = $this->getSerializer()->deserialize($request->getContent(), Address::class, $_format, [ $address = $this->serializer->deserialize($request->getContent(), Address::class, $_format, [
AbstractNormalizer::GROUPS => ['write'], AbstractNormalizer::GROUPS => ['write'],
]); ]);