48 lines
1.6 KiB
PHP
48 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Controller\Teamer\Application;
|
|
|
|
use App\Controller\Traits\ReturnUrlTrait;
|
|
use App\Entity\Application;
|
|
use App\Event\ApplicationDeletedEvent;
|
|
use App\Htmx\HxRedirectResponse;
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
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;
|
|
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
|
|
|
|
class WithdrawController extends AbstractController
|
|
{
|
|
use ReturnUrlTrait;
|
|
|
|
public function __construct(
|
|
private readonly EntityManagerInterface $entityManager,
|
|
private readonly EventDispatcherInterface $eventDispatcher,
|
|
) {
|
|
}
|
|
|
|
#[Route('/teamer/application/withdraw/{uuid}', name: 'app_teamer_application_withdraw')]
|
|
#[IsGranted('WITHDRAW', subject: 'application')]
|
|
public function index(Application $application, Request $request): Response
|
|
{
|
|
if (true === $request->isMethod('POST')) {
|
|
$this->entityManager->remove($application);
|
|
$this->entityManager->flush();
|
|
|
|
$this->eventDispatcher->dispatch(
|
|
new ApplicationDeletedEvent($application),
|
|
ApplicationDeletedEvent::NAME
|
|
);
|
|
|
|
return new HxRedirectResponse($this->getReturnUrl($request, 'app_teamer_index'));
|
|
}
|
|
|
|
return $this->render('teamer/application/modal_withdraw.html.twig', [
|
|
'application' => $application,
|
|
]);
|
|
}
|
|
}
|