mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
AccompanyingPeriodWork: add doctrine event listener to add logged user to referrers collection
This commit is contained in:
parent
55a65ee6e9
commit
da650fa1f2
@ -0,0 +1,31 @@
|
|||||||
|
<?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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\EventListener;
|
||||||
|
|
||||||
|
use Symfony\Component\Security\Core\Security;
|
||||||
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
||||||
|
|
||||||
|
class AccompanyingPeriodWorkEventListener
|
||||||
|
{
|
||||||
|
|
||||||
|
private Security $security;
|
||||||
|
|
||||||
|
public function __construct(Security $security)
|
||||||
|
{
|
||||||
|
$this->security = $security;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function prePersistAccompanyingPeriodWork(AccompanyingPeriodWork $work): void
|
||||||
|
{
|
||||||
|
$work->addReferrer($this->security->getUser());
|
||||||
|
}
|
||||||
|
}
|
@ -12,3 +12,13 @@ services:
|
|||||||
event: 'prePersist'
|
event: 'prePersist'
|
||||||
entity: 'Chill\PersonBundle\Entity\PersonAltName'
|
entity: 'Chill\PersonBundle\Entity\PersonAltName'
|
||||||
method: 'prePersistAltName'
|
method: 'prePersistAltName'
|
||||||
|
|
||||||
|
Chill\PersonBundle\EventListener\AccompanyingPeriodWorkEventListener:
|
||||||
|
autoconfigure: true
|
||||||
|
autowire: true
|
||||||
|
tags:
|
||||||
|
-
|
||||||
|
name: 'doctrine.orm.entity_listener'
|
||||||
|
event: 'prePersist'
|
||||||
|
entity: 'Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork'
|
||||||
|
method: 'prePersistAccompanyingPeriodWork'
|
Loading…
x
Reference in New Issue
Block a user