diff --git a/Controller/AccompanyingPeriodController.php b/Controller/AccompanyingPeriodController.php index c678fe817..5af5bc14f 100644 --- a/Controller/AccompanyingPeriodController.php +++ b/Controller/AccompanyingPeriodController.php @@ -56,7 +56,7 @@ class AccompanyingPeriodController extends Controller $person = $this->_getPerson($person_id); - $event = new PrivacyEvent($person, null, array( + $event = new PrivacyEvent($person, array( 'element_class' => AccompanyingPeriod::class, 'action' => 'list' )); diff --git a/Controller/TimelinePersonController.php b/Controller/TimelinePersonController.php index 3c47baced..35935163d 100644 --- a/Controller/TimelinePersonController.php +++ b/Controller/TimelinePersonController.php @@ -71,7 +71,7 @@ class TimelinePersonController extends Controller $paginator = $paginatorFactory->create($nbItems); - $event = new PrivacyEvent($person); + $event = new PrivacyEvent($person, array('action' => 'timeline')); $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); return $this->render('ChillPersonBundle:Timeline:index.html.twig', array diff --git a/Privacy/PrivacyEvent.php b/Privacy/PrivacyEvent.php index b89328fac..65304f96a 100644 --- a/Privacy/PrivacyEvent.php +++ b/Privacy/PrivacyEvent.php @@ -25,6 +25,14 @@ namespace Chill\PersonBundle\Privacy; use Symfony\Component\EventDispatcher\Event; use Chill\PersonBundle\Entity\Person; +/** + * Class PrivacyEvent + * + * Array $args expects arguments with the following keys: 'element_class', 'element_id', 'action' + * By default, action is set to 'show' + * + * @package Chill\PersonBundle\Privacy + */ class PrivacyEvent extends Event { const PERSON_PRIVACY_EVENT = 'chill_person.privacy_event'; @@ -34,11 +42,6 @@ class PrivacyEvent extends Event */ private $person; - /** - * @var Object - */ - private $element; - /** * @var array */ @@ -53,13 +56,11 @@ class PrivacyEvent extends Event * PrivacyEvent constructor. * * @param Person $person - * @param object $element * @param array $args */ - public function __construct(Person $person, object $element = null, array $args = array('action' => 'show')) + public function __construct(Person $person, array $args = array('action' => 'show')) { $this->person = $person; - $this->element = $element; $this->args = $args; $this->persons = array(); } @@ -95,15 +96,7 @@ class PrivacyEvent extends Event */ public function hasPersons() { - return (count($this->persons) >= 1 ? true : false); - } - - /** - * @return Object - */ - public function getElement() - { - return $this->element; + return count($this->persons) >= 1; } /** diff --git a/Privacy/PrivacyEventSubscriber.php b/Privacy/PrivacyEventSubscriber.php index 0b83c42ef..7fbd0e3e7 100644 --- a/Privacy/PrivacyEventSubscriber.php +++ b/Privacy/PrivacyEventSubscriber.php @@ -69,15 +69,17 @@ class PrivacyEventSubscriber implements EventSubscriberInterface } } - $this->logger->notice("[Privacy Event] A Person Folder has been viewed", array( + $involved = array( 'by_user' => $this->token->getToken()->getUser()->getUsername(), 'by_user_id' => $this->token->getToken()->getUser()->getId(), 'person_id' => $event->getPerson()->getId(), 'persons' => $persons, - 'element_class' => $event->getArgs()['element_class'], - 'element_id' => intval($event->getArgs()['element_id']), - 'action' => $event->getArgs()['action'] - )); + ); + + $this->logger->notice( + "[Privacy Event] A Person Folder has been viewed", + array_merge($involved, $event->getArgs()) + ); dump($event); }