diff --git a/src/Controller/EFNCController.php b/src/Controller/EFNCController.php index df53829..51f7d77 100755 --- a/src/Controller/EFNCController.php +++ b/src/Controller/EFNCController.php @@ -93,7 +93,7 @@ public function formModificationDisplay(int $efncID, Request $request): Response } else if ($request->getMethod() == 'POST') { if ($this->getUser() !== null) { if ($this->authChecker->isGranted('ROLE_ADMIN')) { - $user = $this->getUser(); + $user = $this->getUser()->getUsername(); $form1->handleRequest($request); if ($form1->isValid() && $form1->isSubmitted()) { $result = $this->formModificationService->modifyNCForm( @@ -151,7 +151,8 @@ public function closeEntity(Request $request, string $entityType, int $id): Resp if ($this->getUser() !== null) { if ($this->authChecker->isGranted('ROLE_MASTER_ADMIN')) { - $result = $this->entityDeletionService->closeEntity($entityType, $id); // Implement this method in your service + $user = $this->getUser()->getUsername(); + $result = $this->entityDeletionService->closeEntity($entityType, $id, $commentary = null, $user); // Implement this method in your service if ($result == false) { $this->addFlash('danger', 'L\'élément n\'a pas pu être clôturé'); return $this->redirectToRoute('app_base', []); diff --git a/src/Service/EntityDeletionService.php b/src/Service/EntityDeletionService.php index 6c4bb1f..6c5bcd3 100755 --- a/src/Service/EntityDeletionService.php +++ b/src/Service/EntityDeletionService.php @@ -533,7 +533,7 @@ public function unarchiveEntity(string $entityType, int $id): bool } - public function closeEntity(string $entityType, int $id): bool + public function closeEntity(string $entityType, int $id, string $commentary = null, string $user = null): bool { $repository = null; switch ($entityType) { @@ -553,6 +553,7 @@ public function closeEntity(string $entityType, int $id): bool } if ($entityType === 'efnc') { + $entity->setLastModifier($user); $entity->setArchived(true); $entity->setStatus(true); } diff --git a/src/Service/FormModificationService.php b/src/Service/FormModificationService.php index 227cfb3..27279cb 100755 --- a/src/Service/FormModificationService.php +++ b/src/Service/FormModificationService.php @@ -50,7 +50,8 @@ public function __construct( public function modifyNCForm( EFNC $efnc, Request $request, - FormInterface $form1 + FormInterface $form1, + string $user = null ) { $now = new \DateTime(); diff --git a/templates/services/efnc/modification/form_modification.html.twig b/templates/services/efnc/modification/form_modification.html.twig index af65351..1d6303a 100755 --- a/templates/services/efnc/modification/form_modification.html.twig +++ b/templates/services/efnc/modification/form_modification.html.twig @@ -171,70 +171,95 @@ class="d-grid gap-2 d-md-flex justify-content-md-center mt-5 text-white"> Derniere modification effectué par - {{ EFNC.LastModifier.username|capitalize|split('.')|first }} - {{ EFNC.LastModifier.username|upper|split('.')|last }} + {{ EFNC.LastModifier|capitalize|split('.')|first }} + {{ EFNC.LastModifier|upper|split('.')|last }} {% endif %} -