mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-25 00:53:48 +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:
@@ -36,7 +36,8 @@ class ReportController extends AbstractController
|
||||
private readonly EventDispatcherInterface $eventDispatcher,
|
||||
private readonly AuthorizationHelper $authorizationHelper,
|
||||
private readonly PaginatorFactory $paginator,
|
||||
private readonly TranslatorInterface $translator
|
||||
private readonly TranslatorInterface $translator,
|
||||
private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -50,7 +51,7 @@ class ReportController extends AbstractController
|
||||
*/
|
||||
public function createAction($person_id, $cf_group_id, Request $request)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->managerRegistry->getManager();
|
||||
|
||||
$entity = new Report();
|
||||
$cFGroup = $em->getRepository(\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class)
|
||||
@@ -112,7 +113,7 @@ class ReportController extends AbstractController
|
||||
*/
|
||||
public function editAction(int|string $person_id, int|string $report_id)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->managerRegistry->getManager();
|
||||
|
||||
/** @var Report $report */
|
||||
$report = $em->getRepository('ChillReportBundle:Report')->find($report_id);
|
||||
@@ -154,7 +155,7 @@ class ReportController extends AbstractController
|
||||
*/
|
||||
public function exportAction($cf_group_id, Request $request)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->managerRegistry->getManager();
|
||||
|
||||
$cFGroup = $em->getRepository(\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class)->find($cf_group_id);
|
||||
$reports = $em->getRepository('ChillReportBundle:Report')->findByCFGroup($cFGroup);
|
||||
@@ -180,7 +181,7 @@ class ReportController extends AbstractController
|
||||
*/
|
||||
public function listAction($person_id, Request $request)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->managerRegistry->getManager();
|
||||
|
||||
$person = $em->getRepository(\Chill\PersonBundle\Entity\Person::class)->find($person_id);
|
||||
|
||||
@@ -237,7 +238,7 @@ class ReportController extends AbstractController
|
||||
*/
|
||||
public function newAction($person_id, $cf_group_id, Request $request)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->managerRegistry->getManager();
|
||||
|
||||
$person = $em->getRepository(\Chill\PersonBundle\Entity\Person::class)->find($person_id);
|
||||
$cFGroup = $em
|
||||
@@ -285,7 +286,7 @@ class ReportController extends AbstractController
|
||||
*/
|
||||
public function selectReportTypeAction($person_id, Request $request)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->managerRegistry->getManager();
|
||||
|
||||
$person = $em->getRepository(\Chill\PersonBundle\Entity\Person::class)
|
||||
->find($person_id);
|
||||
@@ -355,7 +356,7 @@ class ReportController extends AbstractController
|
||||
return $this->redirectToRoute('report_export_list', ['cf_group_id' => $cFGroupId]);
|
||||
}
|
||||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->managerRegistry->getManager();
|
||||
|
||||
$cFGroups = $em->getRepository(\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class)
|
||||
->findByEntity(\Chill\ReportBundle\Entity\Report::class);
|
||||
@@ -396,7 +397,7 @@ class ReportController extends AbstractController
|
||||
*/
|
||||
public function updateAction($person_id, $report_id, Request $request)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->managerRegistry->getManager();
|
||||
|
||||
$report = $em->getRepository('ChillReportBundle:Report')->find($report_id);
|
||||
|
||||
@@ -456,7 +457,7 @@ class ReportController extends AbstractController
|
||||
*/
|
||||
public function viewAction($report_id, $person_id)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->managerRegistry->getManager();
|
||||
|
||||
$person = $em->getRepository(\Chill\PersonBundle\Entity\Person::class)->find($person_id);
|
||||
|
||||
|
@@ -1,4 +1,8 @@
|
||||
services:
|
||||
_defaults:
|
||||
autoconfigure: true
|
||||
autowire: true
|
||||
|
||||
Chill\ReportBundle\Controller\ReportController:
|
||||
arguments:
|
||||
$eventDispatcher: '@Symfony\Contracts\EventDispatcher\EventDispatcherInterface'
|
||||
|
Reference in New Issue
Block a user