feat: integrate with htmx
This commit is contained in:
@@ -3,9 +3,11 @@
|
||||
namespace App\Controller\Admin\System\Training;
|
||||
|
||||
use App\Entity\Training;
|
||||
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,19 +20,25 @@ class DeleteController extends AbstractController
|
||||
) {
|
||||
}
|
||||
|
||||
#[Route('/admin/system/training/delete/{id}', name: 'app_admin_system_training_delete', methods: ['POST'])]
|
||||
#[Route('/admin/system/training/delete/{id}', name: 'app_admin_system_training_delete')]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
public function index(Training $training): Response
|
||||
public function index(Training $training, Request $request): Response
|
||||
{
|
||||
$training->setDeleted();
|
||||
$this->entityManager->flush();
|
||||
if (true === $request->isMethod('POST')) {
|
||||
$training->setDeleted();
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->addFlash('success', 'Die Fortbildung wurde gelöscht');
|
||||
$this->logger->info('Delete training', [
|
||||
'training_id' => $training->getId(),
|
||||
'training_name' => $training->getName(),
|
||||
$this->addFlash('success', 'Die Fortbildung wurde gelöscht');
|
||||
$this->logger->info('Delete training', [
|
||||
'training_id' => $training->getId(),
|
||||
'training_name' => $training->getName(),
|
||||
]);
|
||||
|
||||
return new HxRedirectResponse($this->generateUrl('app_admin_system_training_index'));
|
||||
}
|
||||
|
||||
return $this->render('admin/system/training/modal_delete.html.twig', [
|
||||
'training' => $training,
|
||||
]);
|
||||
|
||||
return $this->redirectToRoute('app_admin_system_training_index');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user