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;
}
$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);

View File

@ -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,

View File

@ -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'],
]);