From c5250a10593d3d2e1c165413eaec07d1f77f6fe2 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Tue, 27 Apr 2021 23:07:59 +0200 Subject: [PATCH 1/2] Use injected EntityManager - fix property visibility. --- .../Controller/PersonController.php | 23 ++++++------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonController.php b/src/Bundle/ChillPersonBundle/Controller/PersonController.php index a167dc589..445a17482 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonController.php @@ -49,13 +49,11 @@ use Doctrine\ORM\EntityManagerInterface; class PersonController extends AbstractController { /** - * * @var SimilarPersonMatcher */ protected $similarPersonMatcher; /** - * * @var TranslatorInterface */ protected $translator; @@ -66,34 +64,31 @@ class PersonController extends AbstractController protected $eventDispatcher; /** - * * @var PersonRepository; */ protected $personRepository; /** - * * @var ConfigPersonAltNamesHelper */ protected $configPersonAltNameHelper; /** - * * @var EntityManagerInterface */ - protected $em; + private $em; /** * @var \Psr\Log\LoggerInterface */ private $logger; - + /** * @var ValidatorInterface */ private $validator; - public function __construct( + public function __construct( SimilarPersonMatcher $similarPersonMatcher, TranslatorInterface $translator, EventDispatcherInterface $eventDispatcher, @@ -117,8 +112,7 @@ class PersonController extends AbstractController { $cFGroup = null; - $em = $this->getDoctrine()->getManager(); - $cFDefaultGroup = $em->getRepository("ChillCustomFieldsBundle:CustomFieldsDefaultGroup") + $cFDefaultGroup = $this->em->getRepository("ChillCustomFieldsBundle:CustomFieldsDefaultGroup") ->findOneByEntity("Chill\PersonBundle\Entity\Person"); if($cFDefaultGroup) { @@ -207,8 +201,7 @@ class PersonController extends AbstractController ->trans('The person data has been updated') ); - $em = $this->getDoctrine()->getManager(); - $em->flush(); + $this->em->flush(); $url = $this->generateUrl('chill_person_view', array( 'person_id' => $person->getId() @@ -402,11 +395,9 @@ class PersonController extends AbstractController 'You are not allowed to create this person'); if ($errors->count() === 0) { - $em = $this->getDoctrine()->getManager(); + $this->em->persist($person); - $em->persist($person); - - $em->flush(); + $this->em->flush(); return $this->redirect($this->generateUrl('chill_person_general_edit', array('person_id' => $person->getId()))); From 5448238697256be9cd60773b53678c5adedc5b76 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Tue, 27 Apr 2021 23:11:53 +0200 Subject: [PATCH 2/2] Set final keyword - remove redundant information in phpdoc. --- .../ChillPersonBundle/Controller/PersonController.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonController.php b/src/Bundle/ChillPersonBundle/Controller/PersonController.php index 445a17482..bfb32654e 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonController.php @@ -41,12 +41,7 @@ use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper; use Symfony\Component\Validator\Validator\ValidatorInterface; use Doctrine\ORM\EntityManagerInterface; -/** - * Class PersonController - * - * @package Chill\PersonBundle\Controller - */ -class PersonController extends AbstractController +final class PersonController extends AbstractController { /** * @var SimilarPersonMatcher