From 493cdca479d577d61f77a3a55fe880d9d09fc7a5 Mon Sep 17 00:00:00 2001 From: Mat Date: Tue, 23 Oct 2018 10:07:06 +0200 Subject: [PATCH] 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', [