mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-28 18:43: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:
@@ -58,7 +58,8 @@ class CalendarController extends AbstractController
|
||||
private readonly PersonRepository $personRepository,
|
||||
private readonly AccompanyingPeriodRepository $accompanyingPeriodRepository,
|
||||
private readonly UserRepositoryInterface $userRepository,
|
||||
private readonly TranslatorInterface $translator
|
||||
private readonly TranslatorInterface $translator,
|
||||
private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -68,7 +69,7 @@ class CalendarController extends AbstractController
|
||||
*/
|
||||
public function deleteAction(Request $request, Calendar $entity)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->managerRegistry->getManager();
|
||||
|
||||
[$person, $accompanyingPeriod] = [$entity->getPerson(), $entity->getAccompanyingPeriod()];
|
||||
|
||||
@@ -124,7 +125,7 @@ class CalendarController extends AbstractController
|
||||
return $this->remoteCalendarConnector->getMakeReadyResponse($request->getUri());
|
||||
}
|
||||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->managerRegistry->getManager();
|
||||
|
||||
[$person, $accompanyingPeriod] = [$entity->getPerson(), $entity->getAccompanyingPeriod()];
|
||||
|
||||
@@ -293,7 +294,7 @@ class CalendarController extends AbstractController
|
||||
}
|
||||
|
||||
$view = null;
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->managerRegistry->getManager();
|
||||
|
||||
[$person, $accompanyingPeriod] = $this->getEntity($request);
|
||||
|
||||
@@ -391,7 +392,7 @@ class CalendarController extends AbstractController
|
||||
{
|
||||
throw new \Exception('not implemented');
|
||||
$view = null;
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->managerRegistry->getManager();
|
||||
|
||||
[$user, $accompanyingPeriod] = $this->getEntity($request);
|
||||
|
||||
@@ -531,7 +532,7 @@ class CalendarController extends AbstractController
|
||||
*/
|
||||
private function getEntity(Request $request): array
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->managerRegistry->getManager();
|
||||
$person = $accompanyingPeriod = null;
|
||||
|
||||
if ($request->query->has('person_id')) {
|
||||
|
Reference in New Issue
Block a user