Use injected EntityManager - fix property visibility.

This commit is contained in:
Pol Dellaiera 2021-04-27 23:07:59 +02:00
parent 49c6915c0a
commit c5250a1059

View File

@ -49,13 +49,11 @@ use Doctrine\ORM\EntityManagerInterface;
class PersonController extends AbstractController
{
/**
*
* @var SimilarPersonMatcher
*/
protected $similarPersonMatcher;
/**
*
* @var TranslatorInterface
*/
protected $translator;
@ -66,22 +64,19 @@ class PersonController extends AbstractController
protected $eventDispatcher;
/**
*
* @var PersonRepository;
*/
protected $personRepository;
/**
*
* @var ConfigPersonAltNamesHelper
*/
protected $configPersonAltNameHelper;
/**
*
* @var EntityManagerInterface
*/
protected $em;
private $em;
/**
* @var \Psr\Log\LoggerInterface
@ -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())));