feat: integrate with htmx
This commit is contained in:
@@ -3,9 +3,11 @@
|
||||
namespace App\Controller\Admin\Teamer\TrainingAttendance;
|
||||
|
||||
use App\Entity\TrainingAttendance;
|
||||
use App\Htmx\HxRedirectResponse;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
@@ -18,24 +20,32 @@ class DeleteController extends AbstractController
|
||||
) {
|
||||
}
|
||||
|
||||
#[Route('/admin/teamer/skills/training-attendance/delete/{uuid}', name: 'app_admin_teamer_skills_training_attendance_delete', methods: ['POST'])]
|
||||
#[Route('/admin/teamer/skills/training-attendance/delete/{uuid}', name: 'app_admin_teamer_skills_training_attendance_delete')]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
public function index(TrainingAttendance $attendance): Response
|
||||
public function index(TrainingAttendance $attendance, Request $request): Response
|
||||
{
|
||||
$teamer = $attendance->getTeamer();
|
||||
if (true === $request->isMethod('POST')) {
|
||||
$teamer = $attendance->getTeamer();
|
||||
|
||||
$this->entityManager->remove($attendance);
|
||||
$this->entityManager->flush();
|
||||
$this->entityManager->remove($attendance);
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->addFlash('success', 'Die Teilnahme an der Fortbilundg wurde gelöscht');
|
||||
$this->logger->info('Delete training attendance', [
|
||||
'attendance_id' => $attendance->getId(),
|
||||
'teamer_id' => $teamer->getId(),
|
||||
'teamer_name' => (string) $teamer,
|
||||
'training_id' => $attendance->getTraining()->getId(),
|
||||
'training_name' => $attendance->getTraining()->getName(),
|
||||
$this->addFlash('success', 'Die Teilnahme an der Fortbilundg wurde gelöscht');
|
||||
$this->logger->info('Delete training attendance', [
|
||||
'attendance_id' => $attendance->getId(),
|
||||
'teamer_id' => $teamer->getId(),
|
||||
'teamer_name' => (string) $teamer,
|
||||
'training_id' => $attendance->getTraining()->getId(),
|
||||
'training_name' => $attendance->getTraining()->getName(),
|
||||
]);
|
||||
|
||||
return new HxRedirectResponse($this->generateUrl('app_admin_teamer_skills', [
|
||||
'uuid' => $teamer->getUuid(),
|
||||
]));
|
||||
}
|
||||
|
||||
return $this->render('admin/teamer/training_attendance/modal_delete.html.twig', [
|
||||
'attendance' => $attendance,
|
||||
]);
|
||||
|
||||
return $this->redirectToRoute('app_admin_teamer_skills', ['uuid' => $teamer->getUuid()]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user