46 lines
1.6 KiB
PHP
46 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Controller\Admin\Application;
|
|
|
|
use App\Entity\Application;
|
|
use App\Event\ApplicationRejectedEvent;
|
|
use App\Model\ApplicationCheckDto;
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
use Psr\Log\LoggerInterface;
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
use Symfony\Component\Routing\Annotation\Route;
|
|
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
|
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
|
|
|
|
class RejectController extends AbstractController
|
|
{
|
|
public function __construct(
|
|
private readonly EntityManagerInterface $entityManager,
|
|
private readonly EventDispatcherInterface $eventDispatcher,
|
|
private readonly LoggerInterface $logger
|
|
) {
|
|
}
|
|
|
|
#[Route('/admin/application/reject/{uuid}', name: 'app_admin_application_reject')]
|
|
#[IsGranted('ROLE_ADMINISTRATIVE')]
|
|
#[IsGranted('REJECT', subject: 'application')]
|
|
public function index(Application $application): Response
|
|
{
|
|
$applicationCheckDto = new ApplicationCheckDto($application);
|
|
$this->eventDispatcher->dispatch(new ApplicationRejectedEvent($applicationCheckDto), ApplicationRejectedEvent::NAME);
|
|
|
|
$application->setStatus(Application::STATUS_REJECTED);
|
|
|
|
$this->entityManager->flush();
|
|
|
|
$this->addFlash('success', 'Die Bewerbung wurde abgelehnt');
|
|
$this->logger->info('Reject application', [
|
|
'application' => $application->getUuid(),
|
|
]);
|
|
|
|
return $this->redirectToRoute('app_admin_assignment_detail', [
|
|
'uuid' => $application->getAssignment()->getUuid(),
|
|
]);
|
|
}
|
|
} |