feat: integrate with htmx
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Controller\Teamer\Application;
|
||||
use App\Controller\Traits\ReturnUrlTrait;
|
||||
use App\Entity\Application;
|
||||
use App\Entity\User;
|
||||
use App\Htmx\HxRedirectResponse;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
@@ -27,24 +28,28 @@ class WithdrawController extends AbstractController
|
||||
#[IsGranted('WITHDRAW', subject: 'application')]
|
||||
public function index(Application $application, Request $request): Response
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = $this->getUser();
|
||||
$teamer = $user->getTeamer();
|
||||
$assignment = $application->getAssignment();
|
||||
if (true === $request->isMethod('POST')) {
|
||||
/** @var User $user */
|
||||
$user = $this->getUser();
|
||||
$teamer = $user->getTeamer();
|
||||
$assignment = $application->getAssignment();
|
||||
|
||||
$this->entityManager->remove($application);
|
||||
$this->entityManager->flush();
|
||||
$this->entityManager->remove($application);
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->logger->info('Withdraw application', [
|
||||
'teamer_id' => $teamer->getId(),
|
||||
'teamer_name' => (string) $teamer,
|
||||
'application_id' => $application->getId(),
|
||||
'assignment_id' => $assignment->getId(),
|
||||
'destination' => (string) $assignment->getDestination(),
|
||||
$this->logger->info('Withdraw application', [
|
||||
'teamer_id' => $teamer->getId(),
|
||||
'teamer_name' => (string) $teamer,
|
||||
'application_id' => $application->getId(),
|
||||
'assignment_id' => $assignment->getId(),
|
||||
'destination' => (string) $assignment->getDestination(),
|
||||
]);
|
||||
|
||||
return new HxRedirectResponse($this->getReturnUrl($request, 'app_teamer_index'));
|
||||
}
|
||||
|
||||
return $this->render('teamer/application/modal_withdraw.html.twig', [
|
||||
'application' => $application,
|
||||
]);
|
||||
|
||||
$returnUrl = $this->getReturnUrl($request, 'app_teamer_index');
|
||||
|
||||
return $this->redirect($returnUrl);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user