add PrivacyEvent for documents edit and update

This commit is contained in:
Mat 2018-10-23 10:07:06 +02:00
parent e2cbd65775
commit 493cdca479
2 changed files with 18 additions and 2 deletions

View File

@ -22,4 +22,5 @@ PrivacyEvent branch
===================
- add privacy events to document index / show
- add privacy events to document edit / update

View File

@ -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',
[