diff --git a/Controller/PersonController.php b/Controller/PersonController.php index d89b55a75..bdc1250ae 100644 --- a/Controller/PersonController.php +++ b/Controller/PersonController.php @@ -35,6 +35,8 @@ use Chill\PersonBundle\Security\Authorization\PersonVoter; use Chill\PersonBundle\Search\SimilarPersonMatcher; use Symfony\Component\Translation\TranslatorInterface; use Chill\MainBundle\Search\SearchProvider; +use Chill\PersonBundle\Repository\PersonRepository; +use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper; class PersonController extends Controller { @@ -56,14 +58,31 @@ class PersonController extends Controller */ protected $eventDispatcher; + /** + * + * @var PersonRepository; + */ + protected $personRepository; + + /** + * + * @var ConfigPersonAltNamesHelper + */ + protected $configPersonAltNameHelper; + public function __construct( SimilarPersonMatcher $similarPersonMatcher, TranslatorInterface $translator, - EventDispatcherInterface $eventDispatcher + EventDispatcherInterface $eventDispatcher, + PersonRepository $personRepository, + ConfigPersonAltNamesHelper $configPersonAltNameHelper + ) { $this->similarPersonMatcher = $similarPersonMatcher; $this->translator = $translator; $this->eventDispatcher = $eventDispatcher; + $this->configPersonAltNameHelper = $configPersonAltNameHelper; + $this->personRepository = $personRepository; } public function getCFGroup() @@ -97,8 +116,11 @@ class PersonController extends Controller $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); return $this->render('ChillPersonBundle:Person:view.html.twig', - array("person" => $person, - "cFGroup" => $this->getCFGroup())); + array( + "person" => $person, + "cFGroup" => $this->getCFGroup(), + "alt_names" => $this->configPersonAltNameHelper->getChoices(), + )); } public function editAction($person_id) @@ -373,10 +395,7 @@ class PersonController extends Controller */ private function _getPerson($id) { - $em = $this->getDoctrine()->getManager(); - - $person = $em->getRepository('ChillPersonBundle:Person') - ->find($id); + $person = $this->personRepository->find($id); return $person; } diff --git a/Resources/config/services/controller.yml b/Resources/config/services/controller.yml index 8e2fb9fdf..76829d073 100644 --- a/Resources/config/services/controller.yml +++ b/Resources/config/services/controller.yml @@ -4,6 +4,8 @@ services: $similarPersonMatcher: '@Chill\PersonBundle\Search\SimilarPersonMatcher' $translator: '@Symfony\Component\Translation\TranslatorInterface' $eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface' + $personRepository: '@Chill\PersonBundle\Repository\PersonRepository' + $configPersonAltNameHelper: '@Chill\PersonBundle\Config\ConfigPersonAltNamesHelper' tags: ['controller.service_arguments'] Chill\PersonBundle\Controller\TimelinePersonController: diff --git a/Resources/config/services/templating.yml b/Resources/config/services/templating.yml index 395c3e9f3..813824448 100644 --- a/Resources/config/services/templating.yml +++ b/Resources/config/services/templating.yml @@ -1,4 +1,6 @@ services: Chill\PersonBundle\Templating\Entity\PersonRender: + arguments: + $configAltNamesHelper: '@Chill\PersonBundle\Config\ConfigPersonAltNamesHelper' tags: - 'chill.render_entity' diff --git a/Resources/views/Person/list.html.twig b/Resources/views/Person/list.html.twig index c1f1daf0c..c1ba58b7f 100644 --- a/Resources/views/Person/list.html.twig +++ b/Resources/views/Person/list.html.twig @@ -42,7 +42,7 @@