Integrate audit functionality for "list" actions in GenericDocForAccompanyingPeriodController and GenericDocForPerson

- Added `TriggerAuditInterface` to both controllers and implemented audit triggers with translatable descriptions for listing actions.
- Updated constructor dependencies to include the audit trigger service.
This commit is contained in:
2026-03-02 13:32:23 +01:00
parent 2c252fa79a
commit 67ffbcfbad
2 changed files with 20 additions and 0 deletions

View File

@@ -13,6 +13,8 @@ namespace Chill\DocStoreBundle\Controller;
use Chill\DocStoreBundle\GenericDoc\ManagerInterface;
use Chill\DocStoreBundle\Security\Authorization\AccompanyingCourseDocumentVoter;
use Chill\MainBundle\Audit\TriggerAuditInterface;
use Chill\MainBundle\Entity\AuditTrail;
use Chill\MainBundle\Pagination\PaginatorFactory;
use Chill\MainBundle\Templating\Listing\FilterOrderHelperFactory;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
@@ -20,6 +22,7 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Translation\TranslatableMessage;
final readonly class GenericDocForAccompanyingPeriodController
{
@@ -29,6 +32,7 @@ final readonly class GenericDocForAccompanyingPeriodController
private PaginatorFactory $paginator,
private Security $security,
private \Twig\Environment $twig,
private TriggerAuditInterface $triggerAudit,
) {}
/**
@@ -41,6 +45,12 @@ final readonly class GenericDocForAccompanyingPeriodController
throw new AccessDeniedHttpException('not allowed to see the documents for accompanying period');
}
$this->triggerAudit->triggerAudit(
AuditTrail::AUDIT_LIST,
$accompanyingPeriod,
description: new TranslatableMessage('audit.generic-doc.list_for_accompanying_period')
);
$filterBuilder = $this->filterOrderHelperFactory
->create(self::class)
->addSearchBox()

View File

@@ -13,6 +13,8 @@ namespace Chill\DocStoreBundle\Controller;
use Chill\DocStoreBundle\GenericDoc\ManagerInterface;
use Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter;
use Chill\MainBundle\Audit\TriggerAuditInterface;
use Chill\MainBundle\Entity\AuditTrail;
use Chill\MainBundle\Pagination\PaginatorFactory;
use Chill\MainBundle\Templating\Listing\FilterOrderHelperFactory;
use Chill\PersonBundle\Entity\Person;
@@ -20,6 +22,7 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Translation\TranslatableMessage;
final readonly class GenericDocForPerson
{
@@ -29,6 +32,7 @@ final readonly class GenericDocForPerson
private PaginatorFactory $paginator,
private Security $security,
private \Twig\Environment $twig,
private TriggerAuditInterface $triggerAudit,
) {}
/**
@@ -41,6 +45,12 @@ final readonly class GenericDocForPerson
throw new AccessDeniedHttpException('not allowed to see the documents for person');
}
$this->triggerAudit->triggerAudit(
AuditTrail::AUDIT_LIST,
$person,
description: new TranslatableMessage('audit.generic-doc.list_for_person')
);
$filterBuilder = $this->filterOrderHelperFactory
->create(self::class)
->addSearchBox()