mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-06 23:04:58 +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:
@@ -19,7 +19,7 @@ use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
class AbsenceController extends AbstractController
|
||||
{
|
||||
public function __construct(private readonly ChillSecurity $security) {}
|
||||
public function __construct(private readonly ChillSecurity $security, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {}
|
||||
|
||||
/**
|
||||
* @Route(
|
||||
@@ -36,7 +36,7 @@ class AbsenceController extends AbstractController
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->managerRegistry->getManager();
|
||||
$em->flush();
|
||||
|
||||
return $this->redirectToRoute('chill_main_user_absence_index');
|
||||
@@ -60,7 +60,7 @@ class AbsenceController extends AbstractController
|
||||
$user = $this->security->getUser();
|
||||
|
||||
$user->setAbsenceStart(null);
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->managerRegistry->getManager();
|
||||
$em->flush();
|
||||
|
||||
return $this->redirectToRoute('chill_main_user_absence_index');
|
||||
|
Reference in New Issue
Block a user