From 4c8f1700256fca84383deffb1860dd65547b4bf9 Mon Sep 17 00:00:00 2001 From: Mat Date: Tue, 16 Oct 2018 12:03:54 +0200 Subject: [PATCH] privacyEvent, add event in timeline --- Controller/TimelinePersonController.php | 25 ++++++++++++++++++++++-- Privacy/PrivacyEvent.php | 2 +- Resources/config/services/controller.yml | 4 ++++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/Controller/TimelinePersonController.php b/Controller/TimelinePersonController.php index ad8d46a67..3c47baced 100644 --- a/Controller/TimelinePersonController.php +++ b/Controller/TimelinePersonController.php @@ -19,6 +19,8 @@ namespace Chill\PersonBundle\Controller; +use Chill\PersonBundle\Privacy\PrivacyEvent; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Request; use Symfony\Bundle\FrameworkBundle\Controller\Controller; @@ -30,7 +32,23 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller; */ class TimelinePersonController extends Controller { - + + /** + * @var EventDispatcherInterface + */ + protected $eventDispatcher; + + /** + * TimelinePersonController constructor. + * + * @param EventDispatcherInterface $eventDispatcher + */ + public function __construct(EventDispatcherInterface $eventDispatcher) + { + $this->eventDispatcher = $eventDispatcher; + } + + public function personAction(Request $request, $person_id) { $person = $this->getDoctrine() @@ -52,7 +70,10 @@ class TimelinePersonController extends Controller ); $paginator = $paginatorFactory->create($nbItems); - + + $event = new PrivacyEvent($person); + $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); + return $this->render('ChillPersonBundle:Timeline:index.html.twig', array ( 'timeline' => $timelineBuilder->getTimelineHTML( diff --git a/Privacy/PrivacyEvent.php b/Privacy/PrivacyEvent.php index 2940de3bd..b89328fac 100644 --- a/Privacy/PrivacyEvent.php +++ b/Privacy/PrivacyEvent.php @@ -56,7 +56,7 @@ class PrivacyEvent extends Event * @param object $element * @param array $args */ - public function __construct(Person $person, object $element = null, array $args) + public function __construct(Person $person, object $element = null, array $args = array('action' => 'show')) { $this->person = $person; $this->element = $element; diff --git a/Resources/config/services/controller.yml b/Resources/config/services/controller.yml index d4e232476..7ca377e62 100644 --- a/Resources/config/services/controller.yml +++ b/Resources/config/services/controller.yml @@ -5,3 +5,7 @@ services: $translator: '@Symfony\Component\Translation\TranslatorInterface' $eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface' tags: ['controller.service_arguments'] + + Chill\PersonBundle\Controller\TimelinePersonController: + arguments: + $eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'