63 lines
2.4 KiB
PHP
63 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Controller\Admin\Application;
|
|
|
|
use App\Entity\Application;
|
|
use App\Event\ApplicationStatusEvent;
|
|
use App\Form\ApplicationStatusType;
|
|
use App\Htmx\HxRedirectResponse;
|
|
use App\Model\ApplicationStatusDto;
|
|
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;
|
|
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
|
|
|
|
class StatusController extends AbstractController
|
|
{
|
|
public function __construct(
|
|
private readonly EntityManagerInterface $entityManager,
|
|
private readonly EventDispatcherInterface $eventDispatcher,
|
|
private readonly LoggerInterface $logger
|
|
) {
|
|
}
|
|
|
|
#[Route('/admin/application/status/{uuid}', name: 'app_admin_application_status')]
|
|
#[IsGranted('ROLE_ADMINISTRATIVE')]
|
|
#[IsGranted('STATUS', subject: 'application')]
|
|
public function index(Application $application, Request $request): Response
|
|
{
|
|
$statusDto = new ApplicationStatusDto($application);
|
|
$form = $this->createForm(ApplicationStatusType::class, $statusDto);
|
|
|
|
$form->handleRequest($request);
|
|
|
|
if ($form->isSubmitted() && $form->isValid()) {
|
|
$this->eventDispatcher->dispatch(new ApplicationStatusEvent($statusDto), ApplicationStatusEvent::NAME);
|
|
$application
|
|
->setStatus($statusDto->getStatus())
|
|
->setComment($statusDto->getComment())
|
|
->setCommentVisible($statusDto->isCommentVisible())
|
|
;
|
|
$this->entityManager->flush();
|
|
|
|
$this->addFlash('success', 'Der Status der Bewerbung wurde aktualisiert');
|
|
$this->logger->info('Update application status', [
|
|
'application_id' => $application->getId(),
|
|
'status_new' => $statusDto->getStatus(),
|
|
'teamer' => (string) $application->getTeamer(),
|
|
]);
|
|
|
|
return new HxRedirectResponse($this->generateUrl('app_administrative_assignment_detail', [
|
|
'uuid' => $application->getAssignment()->getUuid(),
|
|
]));
|
|
}
|
|
|
|
return $this->render('admin/application/modal_status.html.twig', [
|
|
'form' => $form->createView(),
|
|
]);
|
|
}
|
|
} |