mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-05 06:14:59 +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:
@@ -26,7 +26,7 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
class ScopeController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $entityManager
|
||||
private readonly EntityManagerInterface $entityManager, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -41,7 +41,7 @@ class ScopeController extends AbstractController
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->managerRegistry->getManager();
|
||||
$em->persist($scope);
|
||||
$em->flush();
|
||||
|
||||
@@ -83,7 +83,7 @@ class ScopeController extends AbstractController
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->managerRegistry->getManager();
|
||||
|
||||
$entities = $em->getRepository(\Chill\MainBundle\Entity\Scope::class)->findAll();
|
||||
|
||||
@@ -113,7 +113,7 @@ class ScopeController extends AbstractController
|
||||
*/
|
||||
public function showAction(mixed $id)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->managerRegistry->getManager();
|
||||
|
||||
$scope = $em->getRepository(\Chill\MainBundle\Entity\Scope::class)->find($id);
|
||||
|
||||
|
Reference in New Issue
Block a user