mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-03-03 20:49:41 +00:00
Add audit functionality for Activity actions
- Introduced `ActivityDisplayer` and `ActivitySubjectConverter` for handling audit display and conversion logic. - Integrated `TriggerAuditInterface` in `ActivityController` and added audit triggers for create, list, update, delete, and view actions with translatable descriptions. - Updated `services.yaml` to register new audit-related services. - Enhanced French translations with audit-related labels for `Activity`.
This commit is contained in:
@@ -19,6 +19,8 @@ use Chill\ActivityBundle\Repository\ActivityRepository;
|
||||
use Chill\ActivityBundle\Repository\ActivityTypeCategoryRepository;
|
||||
use Chill\ActivityBundle\Repository\ActivityTypeRepositoryInterface;
|
||||
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
|
||||
use Chill\MainBundle\Audit\TriggerAuditInterface;
|
||||
use Chill\MainBundle\Entity\AuditTrail;
|
||||
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
|
||||
use Chill\MainBundle\Entity\UserJob;
|
||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||
@@ -45,6 +47,7 @@ use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
use Symfony\Component\Translation\TranslatableMessage;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
final class ActivityController extends AbstractController
|
||||
@@ -69,6 +72,7 @@ final class ActivityController extends AbstractController
|
||||
private readonly TranslatableStringHelperInterface $translatableStringHelper,
|
||||
private readonly PaginatorFactory $paginatorFactory,
|
||||
private readonly ChillSecurity $security,
|
||||
private readonly TriggerAuditInterface $triggerAudit,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -120,6 +124,8 @@ final class ActivityController extends AbstractController
|
||||
'attendee' => $activity->getAttendee(),
|
||||
]);
|
||||
|
||||
$this->triggerAudit->triggerAudit(AuditTrail::AUDIT_DELETE, $activity);
|
||||
|
||||
$this->entityManager->remove($activity);
|
||||
$this->entityManager->flush();
|
||||
|
||||
@@ -190,6 +196,8 @@ final class ActivityController extends AbstractController
|
||||
$this->entityManager->persist($entity);
|
||||
$this->entityManager->flush();
|
||||
|
||||
($this->triggerAudit)(AuditTrail::AUDIT_UPDATE, $entity);
|
||||
|
||||
$params = $this->buildParamsToUrl($person, $accompanyingPeriod);
|
||||
$params['id'] = $entity->getId();
|
||||
|
||||
@@ -256,6 +264,9 @@ final class ActivityController extends AbstractController
|
||||
|
||||
if ($person instanceof Person) {
|
||||
$this->denyAccessUnlessGranted(ActivityVoter::SEE, $person);
|
||||
|
||||
($this->triggerAudit)(AuditTrail::AUDIT_LIST, $person, description: new TranslatableMessage('audit.activity.list_for_person'));
|
||||
|
||||
$count = $this->activityACLAwareRepository->countByPerson($person, ActivityVoter::SEE, $filterArgs);
|
||||
$paginator = $this->paginatorFactory->create($count);
|
||||
$activities = $this->activityACLAwareRepository
|
||||
@@ -278,6 +289,8 @@ final class ActivityController extends AbstractController
|
||||
} elseif ($accompanyingPeriod instanceof AccompanyingPeriod) {
|
||||
$this->denyAccessUnlessGranted(ActivityVoter::SEE, $accompanyingPeriod);
|
||||
|
||||
($this->triggerAudit)(AuditTrail::AUDIT_LIST, $accompanyingPeriod, description: new TranslatableMessage('audit.activity.list_for_accompanying_period'));
|
||||
|
||||
$count = $this->activityACLAwareRepository->countByAccompanyingPeriod($accompanyingPeriod, ActivityVoter::SEE, $filterArgs);
|
||||
$paginator = $this->paginatorFactory->create($count);
|
||||
$activities = $this->activityACLAwareRepository
|
||||
@@ -482,6 +495,8 @@ final class ActivityController extends AbstractController
|
||||
$this->entityManager->persist($entity);
|
||||
$this->entityManager->flush();
|
||||
|
||||
($this->triggerAudit)(AuditTrail::AUDIT_CREATE, $entity);
|
||||
|
||||
if ($form->has('gendocTemplateId') && null !== $form['gendocTemplateId']->getData()) {
|
||||
return $this->redirectToRoute(
|
||||
'chill_docgenerator_generate_from_template',
|
||||
@@ -596,6 +611,8 @@ final class ActivityController extends AbstractController
|
||||
|
||||
$this->denyAccessUnlessGranted(ActivityVoter::SEE, $entity);
|
||||
|
||||
($this->triggerAudit)(AuditTrail::AUDIT_VIEW, $entity);
|
||||
|
||||
$deleteForm = $this->createDeleteForm($entity->getId(), $person, $accompanyingPeriod);
|
||||
|
||||
// TODO
|
||||
|
||||
Reference in New Issue
Block a user