From c9fddffd4bbcab964d5bec0eec7e5c27be23afdf Mon Sep 17 00:00:00 2001 From: Mat Date: Tue, 16 Oct 2018 10:47:50 +0200 Subject: [PATCH] privacyEvent, add event to index and show Actions --- Controller/DocumentPersonController.php | 31 ++++++++++++++++++++++-- Resources/config/services/controller.yml | 3 ++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/Controller/DocumentPersonController.php b/Controller/DocumentPersonController.php index 0ff91e853..81c505d4b 100644 --- a/Controller/DocumentPersonController.php +++ b/Controller/DocumentPersonController.php @@ -5,7 +5,9 @@ namespace Chill\DocStoreBundle\Controller; use Chill\DocStoreBundle\Entity\PersonDocument; use Chill\DocStoreBundle\Form\PersonDocumentType; use Chill\DocStoreBundle\Repository\DocumentRepository; +use Chill\PersonBundle\Privacy\PrivacyEvent; use Symfony\Bundle\FrameworkBundle\Controller\Controller; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; @@ -29,9 +31,21 @@ class DocumentPersonController extends Controller */ protected $translator; - public function __construct(TranslatorInterface $translator) + /** + * @var EventDispatcherInterface + */ + protected $eventDispatcher; + + /** + * DocumentPersonController constructor. + * + * @param TranslatorInterface $translator + * @param EventDispatcherInterface $eventDispatcher + */ + public function __construct(TranslatorInterface $translator, EventDispatcherInterface $eventDispatcher) { $this->translator = $translator; + $this->eventDispatcher = $eventDispatcher; } /** @@ -59,6 +73,12 @@ class DocumentPersonController extends Controller array('date' => 'DESC') ); + $event = new PrivacyEvent($person, array( + 'element_class' => PersonDocument::class, + 'action' => 'index' + )); + $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); + return $this->render( 'ChillDocStoreBundle:PersonDocument:index.html.twig', [ @@ -119,7 +139,14 @@ class DocumentPersonController extends Controller { $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); $this->denyAccessUnlessGranted('CHILL_PERSON_DOCUMENT_SEE', $document); - + + $event = new PrivacyEvent($person, array( + 'element_class' => PersonDocument::class, + 'element_id' => $document->getId(), + 'action' => 'show' + )); + $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); + return $this->render( 'ChillDocStoreBundle:PersonDocument:show.html.twig', ['document' => $document, 'person' => $person]); diff --git a/Resources/config/services/controller.yml b/Resources/config/services/controller.yml index 379d36829..0a2798508 100644 --- a/Resources/config/services/controller.yml +++ b/Resources/config/services/controller.yml @@ -5,4 +5,5 @@ services: Chill\DocStoreBundle\Controller\DocumentPersonController: autowire: true - \ No newline at end of file + arguments: + $eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'