mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
privacyEvent, add event on list and view actions
This commit is contained in:
parent
b4c9cf06be
commit
43a2e4705f
@ -21,6 +21,8 @@
|
||||
|
||||
namespace Chill\ReportBundle\Controller;
|
||||
|
||||
use Chill\PersonBundle\Privacy\PrivacyEvent;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
@ -38,6 +40,22 @@ use Chill\ReportBundle\Form\ReportType;
|
||||
*/
|
||||
class ReportController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var EventDispatcherInterface
|
||||
*/
|
||||
protected $eventDispatcher;
|
||||
|
||||
/**
|
||||
* ReportController constructor.
|
||||
*
|
||||
* @param EventDispatcherInterface $eventDispatcher
|
||||
*/
|
||||
public function __construct(EventDispatcherInterface $eventDispatcher)
|
||||
{
|
||||
$this->eventDispatcher = $eventDispatcher;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* List all the report entities for a given person.
|
||||
*
|
||||
@ -78,6 +96,12 @@ class ReportController extends Controller
|
||||
->getResult()
|
||||
;
|
||||
|
||||
$event = new PrivacyEvent($person, array(
|
||||
'element_class' => Report::class,
|
||||
'action' => 'list'
|
||||
));
|
||||
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
|
||||
|
||||
return $this->render('ChillReportBundle:Report:list.html.twig', array(
|
||||
'reports' => $reports,
|
||||
'person' => $person,
|
||||
@ -379,7 +403,15 @@ class ReportController extends Controller
|
||||
}
|
||||
|
||||
$this->denyAccessUnlessGranted('CHILL_REPORT_SEE', $entity);
|
||||
|
||||
|
||||
|
||||
$event = new PrivacyEvent($person, array(
|
||||
'element_class' => Report::class,
|
||||
'element_id' => intval($report_id),
|
||||
'action' => 'view'
|
||||
));
|
||||
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
|
||||
|
||||
return $this->render('ChillReportBundle:Report:view.html.twig', array(
|
||||
'entity' => $entity,
|
||||
'person' => $person,
|
||||
|
@ -29,6 +29,7 @@ class ChillReportExtension extends Extension implements PrependExtensionInterfac
|
||||
$loader->load('services.yml');
|
||||
$loader->load('services/fixtures.yml');
|
||||
$loader->load('services/export.yml');
|
||||
$loader->load('services/controller.yml');
|
||||
}
|
||||
|
||||
/**
|
||||
|
4
Resources/config/services/controller.yml
Normal file
4
Resources/config/services/controller.yml
Normal file
@ -0,0 +1,4 @@
|
||||
services:
|
||||
Chill\ReportBundle\Controller\ReportController:
|
||||
arguments:
|
||||
$eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'
|
Loading…
x
Reference in New Issue
Block a user