Merge branch '14-correctif-creation-personne' into 'master'

Use injected EntityManager - fix property visibility.

See merge request Chill-Projet/chill-bundles!25
This commit is contained in:
Julien Fastré 2021-04-28 08:36:34 +00:00
commit 4c82e65c1f

View File

@ -41,21 +41,14 @@ use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
use Symfony\Component\Validator\Validator\ValidatorInterface; use Symfony\Component\Validator\Validator\ValidatorInterface;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
/** final class PersonController extends AbstractController
* Class PersonController
*
* @package Chill\PersonBundle\Controller
*/
class PersonController extends AbstractController
{ {
/** /**
*
* @var SimilarPersonMatcher * @var SimilarPersonMatcher
*/ */
protected $similarPersonMatcher; protected $similarPersonMatcher;
/** /**
*
* @var TranslatorInterface * @var TranslatorInterface
*/ */
protected $translator; protected $translator;
@ -66,34 +59,31 @@ class PersonController extends AbstractController
protected $eventDispatcher; protected $eventDispatcher;
/** /**
*
* @var PersonRepository; * @var PersonRepository;
*/ */
protected $personRepository; protected $personRepository;
/** /**
*
* @var ConfigPersonAltNamesHelper * @var ConfigPersonAltNamesHelper
*/ */
protected $configPersonAltNameHelper; protected $configPersonAltNameHelper;
/** /**
*
* @var EntityManagerInterface * @var EntityManagerInterface
*/ */
protected $em; private $em;
/** /**
* @var \Psr\Log\LoggerInterface * @var \Psr\Log\LoggerInterface
*/ */
private $logger; private $logger;
/** /**
* @var ValidatorInterface * @var ValidatorInterface
*/ */
private $validator; private $validator;
public function __construct( public function __construct(
SimilarPersonMatcher $similarPersonMatcher, SimilarPersonMatcher $similarPersonMatcher,
TranslatorInterface $translator, TranslatorInterface $translator,
EventDispatcherInterface $eventDispatcher, EventDispatcherInterface $eventDispatcher,
@ -117,8 +107,7 @@ class PersonController extends AbstractController
{ {
$cFGroup = null; $cFGroup = null;
$em = $this->getDoctrine()->getManager(); $cFDefaultGroup = $this->em->getRepository("ChillCustomFieldsBundle:CustomFieldsDefaultGroup")
$cFDefaultGroup = $em->getRepository("ChillCustomFieldsBundle:CustomFieldsDefaultGroup")
->findOneByEntity("Chill\PersonBundle\Entity\Person"); ->findOneByEntity("Chill\PersonBundle\Entity\Person");
if($cFDefaultGroup) { if($cFDefaultGroup) {
@ -207,8 +196,7 @@ class PersonController extends AbstractController
->trans('The person data has been updated') ->trans('The person data has been updated')
); );
$em = $this->getDoctrine()->getManager(); $this->em->flush();
$em->flush();
$url = $this->generateUrl('chill_person_view', array( $url = $this->generateUrl('chill_person_view', array(
'person_id' => $person->getId() 'person_id' => $person->getId()
@ -402,11 +390,9 @@ class PersonController extends AbstractController
'You are not allowed to create this person'); 'You are not allowed to create this person');
if ($errors->count() === 0) { if ($errors->count() === 0) {
$em = $this->getDoctrine()->getManager(); $this->em->persist($person);
$em->persist($person); $this->em->flush();
$em->flush();
return $this->redirect($this->generateUrl('chill_person_general_edit', return $this->redirect($this->generateUrl('chill_person_general_edit',
array('person_id' => $person->getId()))); array('person_id' => $person->getId())));