mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-03-13 17:37:45 +00:00
Integrate audit functionality across Person and PersonResource controllers
- Added `TriggerAuditInterface` to enable seamless audit event handling. - Implemented audit triggers for create, update, delete, and view actions. - Enhanced controllers to include translatable audit descriptions for better tracking of actions.
This commit is contained in:
@@ -11,7 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Controller;
|
||||
|
||||
use Chill\MainBundle\Audit\AuditEvent;
|
||||
use Chill\MainBundle\Audit\TriggerAuditInterface;
|
||||
use Chill\MainBundle\Entity\AuditTrail;
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
|
||||
use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
|
||||
@@ -33,6 +33,7 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Translation\TranslatableMessage;
|
||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use function hash;
|
||||
@@ -48,6 +49,7 @@ final class PersonController extends AbstractController
|
||||
private readonly ConfigPersonAltNamesHelper $configPersonAltNameHelper,
|
||||
private readonly ValidatorInterface $validator,
|
||||
private readonly EntityManagerInterface $em,
|
||||
private readonly TriggerAuditInterface $triggerAudit,
|
||||
) {}
|
||||
|
||||
public function getCFGroup()
|
||||
@@ -78,6 +80,7 @@ final class PersonController extends AbstractController
|
||||
|
||||
$event = new PrivacyEvent($person);
|
||||
$this->eventDispatcher->dispatch($event, PrivacyEvent::PERSON_PRIVACY_EVENT);
|
||||
($this->triggerAudit)(AuditTrail::AUDIT_VIEW, $person, description: new TranslatableMessage('audit.household.list_person_file'));
|
||||
|
||||
return $this->render(
|
||||
'@ChillPerson/Person/household_history.html.twig',
|
||||
@@ -133,6 +136,8 @@ final class PersonController extends AbstractController
|
||||
) {
|
||||
$this->em->persist($person);
|
||||
|
||||
($this->triggerAudit)(AuditTrail::AUDIT_CREATE, $person);
|
||||
|
||||
$this->em->flush();
|
||||
$this->lastPostDataReset();
|
||||
|
||||
@@ -151,6 +156,7 @@ final class PersonController extends AbstractController
|
||||
|
||||
$this->em->persist($member);
|
||||
$this->em->persist($household);
|
||||
($this->triggerAudit)(AuditTrail::AUDIT_CREATE, $household, [$household]);
|
||||
$this->em->flush();
|
||||
|
||||
if ($form->get('createHousehold')->isClicked()) {
|
||||
@@ -206,7 +212,7 @@ final class PersonController extends AbstractController
|
||||
'You are not allowed to see this person.'
|
||||
);
|
||||
|
||||
$this->eventDispatcher->dispatch(new AuditEvent(AuditTrail::AUDIT_VIEW, $person));
|
||||
($this->triggerAudit)(AuditTrail::AUDIT_VIEW, $person);
|
||||
|
||||
return $this->render(
|
||||
'@ChillPerson/Person/view.html.twig',
|
||||
|
||||
Reference in New Issue
Block a user