mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-01 12:33:49 +00:00
Refactor code to directly use Doctrine's ManagerRegistry
Replaced most of the invocations of getDoctrine()->getManager() with ManagerRegistry->getManager(), and added ManagerRegistry injection to controllers where needed. This is part of an ongoing effort to improve code clarity, and avoid unnecessary method chaining in various parts of the codebase.
This commit is contained in:
@@ -46,7 +46,7 @@ use Symfony\Component\Workflow\Registry;
|
||||
|
||||
final class AccompanyingCourseApiController extends ApiController
|
||||
{
|
||||
public function __construct(private readonly AccompanyingPeriodRepository $accompanyingPeriodRepository, private readonly AccompanyingPeriodACLAwareRepository $accompanyingPeriodACLAwareRepository, private readonly EventDispatcherInterface $eventDispatcher, private readonly ReferralsSuggestionInterface $referralAvailable, private readonly Registry $registry, private readonly ValidatorInterface $validator) {}
|
||||
public function __construct(private readonly AccompanyingPeriodRepository $accompanyingPeriodRepository, private readonly AccompanyingPeriodACLAwareRepository $accompanyingPeriodACLAwareRepository, private readonly EventDispatcherInterface $eventDispatcher, private readonly ReferralsSuggestionInterface $referralAvailable, private readonly Registry $registry, private readonly ValidatorInterface $validator, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {}
|
||||
|
||||
public function commentApi($id, Request $request, string $_format): Response
|
||||
{
|
||||
@@ -72,7 +72,7 @@ final class AccompanyingCourseApiController extends ApiController
|
||||
|
||||
$workflow->apply($accompanyingPeriod, 'confirm');
|
||||
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
$this->managerRegistry->getManager()->flush();
|
||||
|
||||
return $this->json($accompanyingPeriod, Response::HTTP_OK, [], [
|
||||
'groups' => ['read'],
|
||||
@@ -172,7 +172,7 @@ final class AccompanyingCourseApiController extends ApiController
|
||||
return $this->json($errors, 422);
|
||||
}
|
||||
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
$this->managerRegistry->getManager()->flush();
|
||||
|
||||
return $this->json($participation, 200, [], ['groups' => ['read']]);
|
||||
}
|
||||
@@ -220,7 +220,7 @@ final class AccompanyingCourseApiController extends ApiController
|
||||
return $this->json($errors, 422);
|
||||
}
|
||||
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
$this->managerRegistry->getManager()->flush();
|
||||
|
||||
return $this->json($accompanyingPeriod->getRequestor(), 200, [], ['groups' => ['read']]);
|
||||
}
|
||||
@@ -289,7 +289,7 @@ final class AccompanyingCourseApiController extends ApiController
|
||||
|
||||
$accompanyingCourse->setConfidential(!$accompanyingCourse->isConfidential());
|
||||
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
$this->managerRegistry->getManager()->flush();
|
||||
}
|
||||
|
||||
return $this->json($accompanyingCourse->isConfidential(), Response::HTTP_OK, [], ['groups' => ['read']]);
|
||||
@@ -307,7 +307,7 @@ final class AccompanyingCourseApiController extends ApiController
|
||||
|
||||
$status = 'regular' === $accompanyingCourse->getIntensity() ? 'occasional' : 'regular';
|
||||
$accompanyingCourse->setIntensity($status);
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
$this->managerRegistry->getManager()->flush();
|
||||
}
|
||||
|
||||
return $this->json($accompanyingCourse->getIntensity(), Response::HTTP_OK, [], ['groups' => ['read']]);
|
||||
|
Reference in New Issue
Block a user