feat: integrate with htmx
This commit is contained in:
@@ -3,9 +3,11 @@
|
||||
namespace App\Controller\Admin\System\JobProfile;
|
||||
|
||||
use App\Entity\JobProfile;
|
||||
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/job-profile/delete/{id}', name: 'app_admin_system_job_profile_delete', methods: ['POST'])]
|
||||
#[Route('/admin/system/job-profile/delete/{id}', name: 'app_admin_system_job_profile_delete')]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
public function index(JobProfile $jobProfile): Response
|
||||
public function index(JobProfile $jobProfile, Request $request): Response
|
||||
{
|
||||
$jobProfile->setDeleted();
|
||||
$this->entityManager->flush();
|
||||
if (true === $request->isMethod('POST')) {
|
||||
$jobProfile->setDeleted();
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->addFlash('success', 'Das Job-Profil wurde gelöscht');
|
||||
$this->logger->info('Delete job-profile', [
|
||||
'job_profile_id' => $jobProfile->getId(),
|
||||
'job_profile_name' => $jobProfile->getName(),
|
||||
$this->addFlash('success', 'Das Job-Profil wurde gelöscht');
|
||||
$this->logger->info('Delete job-profile', [
|
||||
'job_profile_id' => $jobProfile->getId(),
|
||||
'job_profile_name' => $jobProfile->getName(),
|
||||
]);
|
||||
|
||||
return new HxRedirectResponse($this->generateUrl('app_admin_system_job_profile_index'));
|
||||
}
|
||||
|
||||
return $this->render('admin/system/job_profile/modal_delete.html.twig', [
|
||||
'jobProfile' => $jobProfile,
|
||||
]);
|
||||
|
||||
return $this->redirectToRoute('app_admin_system_job_profile_index');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user