mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-05 22:35:01 +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:
@@ -22,6 +22,9 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
*/
|
||||
class StatusController extends AbstractController
|
||||
{
|
||||
public function __construct(private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry)
|
||||
{
|
||||
}
|
||||
/**
|
||||
* Creates a new Status entity.
|
||||
*
|
||||
@@ -34,7 +37,7 @@ class StatusController extends AbstractController
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->managerRegistry->getManager();
|
||||
$em->persist($entity);
|
||||
$em->flush();
|
||||
|
||||
@@ -58,7 +61,7 @@ class StatusController extends AbstractController
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->managerRegistry->getManager();
|
||||
$entity = $em->getRepository(\Chill\EventBundle\Entity\Status::class)->find($id);
|
||||
|
||||
if (!$entity) {
|
||||
@@ -79,7 +82,7 @@ class StatusController extends AbstractController
|
||||
*/
|
||||
public function editAction(mixed $id)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->managerRegistry->getManager();
|
||||
|
||||
$entity = $em->getRepository(\Chill\EventBundle\Entity\Status::class)->find($id);
|
||||
|
||||
@@ -104,7 +107,7 @@ class StatusController extends AbstractController
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->managerRegistry->getManager();
|
||||
|
||||
$entities = $em->getRepository(\Chill\EventBundle\Entity\Status::class)->findAll();
|
||||
|
||||
@@ -136,7 +139,7 @@ class StatusController extends AbstractController
|
||||
*/
|
||||
public function showAction(mixed $id)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->managerRegistry->getManager();
|
||||
|
||||
$entity = $em->getRepository(\Chill\EventBundle\Entity\Status::class)->find($id);
|
||||
|
||||
@@ -159,7 +162,7 @@ class StatusController extends AbstractController
|
||||
*/
|
||||
public function updateAction(Request $request, mixed $id)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->managerRegistry->getManager();
|
||||
|
||||
$entity = $em->getRepository(\Chill\EventBundle\Entity\Status::class)->find($id);
|
||||
|
||||
|
Reference in New Issue
Block a user