diff --git a/Controller/ReportController.php b/Controller/ReportController.php index 6d9af377e..d24731bdd 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -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, diff --git a/DependencyInjection/ChillReportExtension.php b/DependencyInjection/ChillReportExtension.php index 56d8effc5..54d09580c 100644 --- a/DependencyInjection/ChillReportExtension.php +++ b/DependencyInjection/ChillReportExtension.php @@ -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'); } /** diff --git a/Resources/config/services/controller.yml b/Resources/config/services/controller.yml new file mode 100644 index 000000000..033cf4c15 --- /dev/null +++ b/Resources/config/services/controller.yml @@ -0,0 +1,4 @@ +services: + Chill\ReportBundle\Controller\ReportController: + arguments: + $eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'