mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
Merge branch 'privacyEvent'
This commit is contained in:
commit
10577e1735
@ -18,9 +18,11 @@ Version 1.5.3
|
|||||||
|
|
||||||
- the javascript for uploading a file now works within collections, listening to collection events.
|
- the javascript for uploading a file now works within collections, listening to collection events.
|
||||||
|
|
||||||
`Master` branch
|
Master branch
|
||||||
===============
|
=============
|
||||||
|
|
||||||
- replace default message on download button below dropzone ;
|
- replace default message on download button below dropzone ;
|
||||||
- launch event when dropzone is initialized, to allow to customize events on dropzone;
|
- launch event when dropzone is initialized, to allow to customize events on dropzone;
|
||||||
|
|
||||||
|
- add privacy events to document index / show
|
||||||
|
- add privacy events to document edit / update
|
||||||
|
@ -5,7 +5,9 @@ namespace Chill\DocStoreBundle\Controller;
|
|||||||
use Chill\DocStoreBundle\Entity\PersonDocument;
|
use Chill\DocStoreBundle\Entity\PersonDocument;
|
||||||
use Chill\DocStoreBundle\Form\PersonDocumentType;
|
use Chill\DocStoreBundle\Form\PersonDocumentType;
|
||||||
use Chill\DocStoreBundle\Repository\DocumentRepository;
|
use Chill\DocStoreBundle\Repository\DocumentRepository;
|
||||||
|
use Chill\PersonBundle\Privacy\PrivacyEvent;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
@ -29,9 +31,21 @@ class DocumentPersonController extends Controller
|
|||||||
*/
|
*/
|
||||||
protected $translator;
|
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->translator = $translator;
|
||||||
|
$this->eventDispatcher = $eventDispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,6 +73,12 @@ class DocumentPersonController extends Controller
|
|||||||
array('date' => 'DESC')
|
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(
|
return $this->render(
|
||||||
'ChillDocStoreBundle:PersonDocument:index.html.twig',
|
'ChillDocStoreBundle:PersonDocument:index.html.twig',
|
||||||
[
|
[
|
||||||
@ -119,7 +139,14 @@ class DocumentPersonController extends Controller
|
|||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person);
|
$this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person);
|
||||||
$this->denyAccessUnlessGranted('CHILL_PERSON_DOCUMENT_SEE', $document);
|
$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(
|
return $this->render(
|
||||||
'ChillDocStoreBundle:PersonDocument:show.html.twig',
|
'ChillDocStoreBundle:PersonDocument:show.html.twig',
|
||||||
['document' => $document, 'person' => $person]);
|
['document' => $document, 'person' => $person]);
|
||||||
@ -147,14 +174,29 @@ class DocumentPersonController extends Controller
|
|||||||
$this->getDoctrine()->getManager()->flush();
|
$this->getDoctrine()->getManager()->flush();
|
||||||
|
|
||||||
$this->addFlash('success', $this->translator->trans("The document is successfully updated"));
|
$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(
|
return $this->redirectToRoute(
|
||||||
'person_document_edit',
|
'person_document_edit',
|
||||||
['id' => $document->getId(), 'person' => $person->getId()]);
|
['id' => $document->getId(), 'person' => $person->getId()]);
|
||||||
|
|
||||||
} elseif ($form->isSubmitted() and !$form->isValid()) {
|
} elseif ($form->isSubmitted() and !$form->isValid()) {
|
||||||
$this->addFlash('error', $this->translator->trans("This form contains errors"));
|
$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(
|
return $this->render(
|
||||||
'ChillDocStoreBundle:PersonDocument:edit.html.twig',
|
'ChillDocStoreBundle:PersonDocument:edit.html.twig',
|
||||||
[
|
[
|
||||||
|
@ -5,4 +5,5 @@ services:
|
|||||||
|
|
||||||
Chill\DocStoreBundle\Controller\DocumentPersonController:
|
Chill\DocStoreBundle\Controller\DocumentPersonController:
|
||||||
autowire: true
|
autowire: true
|
||||||
|
arguments:
|
||||||
|
$eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user