mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-28 02:23:51 +00:00
cs: Fix code style (safe rules only).
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Privacy;
|
||||
|
||||
/*
|
||||
@@ -22,31 +29,30 @@ namespace Chill\PersonBundle\Privacy;
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
|
||||
class AccompanyingPeriodPrivacyEvent extends Event
|
||||
{
|
||||
public const ACCOMPANYING_PERIOD_PRIVACY_EVENT = 'chill_person.accompanying_period_privacy_event';
|
||||
|
||||
protected AccompanyingPeriod $period;
|
||||
|
||||
protected array $args;
|
||||
|
||||
protected AccompanyingPeriod $period;
|
||||
|
||||
public function __construct($period, $args = [])
|
||||
{
|
||||
$this->period = $period;
|
||||
$this->args = $args;
|
||||
}
|
||||
|
||||
public function getPeriod(): AccompanyingPeriod
|
||||
{
|
||||
return $this->period;
|
||||
}
|
||||
|
||||
public function getArgs(): array
|
||||
{
|
||||
return $this->args;
|
||||
}
|
||||
|
||||
public function getPeriod(): AccompanyingPeriod
|
||||
{
|
||||
return $this->period;
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Privacy;
|
||||
|
||||
/*
|
||||
@@ -22,83 +29,51 @@ namespace Chill\PersonBundle\Privacy;
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
|
||||
/**
|
||||
* Class PrivacyEvent
|
||||
* 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';
|
||||
|
||||
/**
|
||||
* @var Person
|
||||
*/
|
||||
private $person;
|
||||
|
||||
public const PERSON_PRIVACY_EVENT = 'chill_person.privacy_event';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $args;
|
||||
|
||||
|
||||
/**
|
||||
* @var Person
|
||||
*/
|
||||
private $person;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $persons;
|
||||
|
||||
|
||||
/**
|
||||
* PrivacyEvent constructor.
|
||||
*
|
||||
* @param Person $person
|
||||
* @param array $args
|
||||
*/
|
||||
public function __construct(Person $person, array $args = array('action' => 'show'))
|
||||
public function __construct(Person $person, array $args = ['action' => 'show'])
|
||||
{
|
||||
$this->person = $person;
|
||||
$this->args = $args;
|
||||
$this->persons = array();
|
||||
$this->persons = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Person
|
||||
*/
|
||||
public function getPerson()
|
||||
{
|
||||
return $this->person;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Person $person
|
||||
*/
|
||||
|
||||
public function addPerson(Person $person)
|
||||
{
|
||||
$this->persons[] = $person;
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array $persons
|
||||
*/
|
||||
public function getPersons()
|
||||
{
|
||||
return $this->persons;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasPersons()
|
||||
{
|
||||
return count($this->persons) >= 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
@@ -106,5 +81,28 @@ class PrivacyEvent extends Event
|
||||
{
|
||||
return $this->args;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Person
|
||||
*/
|
||||
public function getPerson()
|
||||
{
|
||||
return $this->person;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array $persons
|
||||
*/
|
||||
public function getPersons()
|
||||
{
|
||||
return $this->persons;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasPersons()
|
||||
{
|
||||
return count($this->persons) >= 1;
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Privacy;
|
||||
|
||||
/*
|
||||
@@ -22,15 +29,14 @@ namespace Chill\PersonBundle\Privacy;
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Privacy\AccompanyingPeriodPrivacyEvent;
|
||||
use function array_map;
|
||||
|
||||
class PrivacyEventSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @var LoggerInterface
|
||||
*/
|
||||
@@ -43,8 +49,6 @@ class PrivacyEventSubscriber implements EventSubscriberInterface
|
||||
|
||||
/**
|
||||
* PrivacyEventSubscriber constructor.
|
||||
*
|
||||
* @param LoggerInterface $logger
|
||||
*/
|
||||
public function __construct(LoggerInterface $logger, TokenStorageInterface $token)
|
||||
{
|
||||
@@ -56,11 +60,11 @@ class PrivacyEventSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
return [
|
||||
PrivacyEvent::PERSON_PRIVACY_EVENT => [
|
||||
['onPrivacyEvent']
|
||||
['onPrivacyEvent'],
|
||||
],
|
||||
AccompanyingPeriodPrivacyEvent::ACCOMPANYING_PERIOD_PRIVACY_EVENT => [
|
||||
['onAccompanyingPeriodPrivacyEvent']
|
||||
]
|
||||
['onAccompanyingPeriodPrivacyEvent'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -69,11 +73,11 @@ class PrivacyEventSubscriber implements EventSubscriberInterface
|
||||
$involved = $this->getInvolved();
|
||||
$involved['period_id'] = $event->getPeriod()->getId();
|
||||
$involved['persons'] = $event->getPeriod()->getPersons()
|
||||
->map(function(Person $p) { return $p->getId(); })
|
||||
->map(function (Person $p) { return $p->getId(); })
|
||||
->toArray();
|
||||
|
||||
$this->logger->notice(
|
||||
"[Privacy Event] An accompanying period has been viewed",
|
||||
'[Privacy Event] An accompanying period has been viewed',
|
||||
array_merge($involved, $event->getArgs())
|
||||
);
|
||||
}
|
||||
@@ -92,14 +96,14 @@ class PrivacyEventSubscriber implements EventSubscriberInterface
|
||||
$involved['person_id'] = $event->getPerson()->getId();
|
||||
|
||||
if ($event->hasPersons()) {
|
||||
$involved['persons'] = \array_map(
|
||||
function(Person $p) { return $p->getId(); },
|
||||
$involved['persons'] = array_map(
|
||||
function (Person $p) { return $p->getId(); },
|
||||
$event->getPersons()
|
||||
);
|
||||
}
|
||||
|
||||
$this->logger->notice(
|
||||
"[Privacy Event] A Person Folder has been viewed",
|
||||
'[Privacy Event] A Person Folder has been viewed',
|
||||
array_merge($involved, $event->getArgs())
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user