From c9fddffd4bbcab964d5bec0eec7e5c27be23afdf Mon Sep 17 00:00:00 2001 From: Mat Date: Tue, 16 Oct 2018 10:47:50 +0200 Subject: [PATCH 1/3] 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' From c1da0f712ced095912769643f633ad32d8538850 Mon Sep 17 00:00:00 2001 From: Mat Date: Fri, 19 Oct 2018 13:29:37 +0200 Subject: [PATCH 2/3] privacyEvent, update changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4136b5f0a..6337b66f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,3 +13,8 @@ Version 1.5.2 You must add `"dropzone": "^5.5.1"` to your dependencies in `packages.json` at the root project. +PrivacyEvent branch +=================== + +- add privacy events to document index / show + From 493cdca479d577d61f77a3a55fe880d9d09fc7a5 Mon Sep 17 00:00:00 2001 From: Mat Date: Tue, 23 Oct 2018 10:07:06 +0200 Subject: [PATCH 3/3] add PrivacyEvent for documents edit and update --- CHANGELOG.md | 1 + Controller/DocumentPersonController.php | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 585ce8d2f..b60ee20b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,4 +22,5 @@ PrivacyEvent branch =================== - add privacy events to document index / show +- add privacy events to document edit / update diff --git a/Controller/DocumentPersonController.php b/Controller/DocumentPersonController.php index 81c505d4b..f6f074610 100644 --- a/Controller/DocumentPersonController.php +++ b/Controller/DocumentPersonController.php @@ -174,14 +174,29 @@ class DocumentPersonController extends Controller $this->getDoctrine()->getManager()->flush(); $this->addFlash('success', $this->translator->trans("The document is successfully updated")); - + + $event = new PrivacyEvent($person, array( + 'element_class' => PersonDocument::class, + 'element_id' => $document->getId(), + 'action' => 'update' + )); + $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); + return $this->redirectToRoute( 'person_document_edit', ['id' => $document->getId(), 'person' => $person->getId()]); + } elseif ($form->isSubmitted() and !$form->isValid()) { $this->addFlash('error', $this->translator->trans("This form contains errors")); } - + + $event = new PrivacyEvent($person, array( + 'element_class' => PersonDocument::class, + 'element_id' => $document->getId(), + 'action' => 'edit' + )); + $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); + return $this->render( 'ChillDocStoreBundle:PersonDocument:edit.html.twig', [