Commit 43a2e470 authored by Mat's avatar Mat
Browse files

privacyEvent, add event on list and view actions

parent b4c9cf06
Pipeline #80543 failed with stage
in 41 seconds
......@@ -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');
}
/**
......
services:
Chill\ReportBundle\Controller\ReportController:
arguments:
$eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment