WIP: Implement application handling

This commit is contained in:
Björn Fromme
2023-10-11 15:43:33 +02:00
parent b472dab6c8
commit 79e4fe0f33
7 changed files with 193 additions and 29 deletions
@@ -0,0 +1,38 @@
<?php
namespace App\Controller\Admin\Application;
use App\Entity\Application;
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;
class DeleteController extends AbstractController
{
public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly LoggerInterface $logger
) {
}
#[Route('/admin/application/delete/{uuid}', name: 'app_admin_application_delete')]
#[IsGranted('ROLE_ADMINISTRATIVE')]
#[IsGranted('DELETE', subject: 'application')]
public function index(Application $application): Response
{
$this->entityManager->remove($application);
$this->entityManager->flush();
$this->addFlash('success', 'Die Bewerbung wurde gelöscht');
$this->logger->info('Delete application', [
'application' => $application->getUuid(),
]);
return $this->redirectToRoute('app_admin_assignment_detail', [
'uuid' => $application->getAssignment()->getUuid(),
]);
}
}
@@ -1,6 +1,6 @@
<?php
namespace App\Controller\Admin\DIsposition;
namespace App\Controller\Admin\Application;
use App\Entity\Application;
use App\Entity\Disposition;
@@ -11,7 +11,7 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
class CreateController extends AbstractController
class DisposeController extends AbstractController
{
public function __construct(
private readonly EntityManagerInterface $entityManager,
@@ -19,8 +19,9 @@ class CreateController extends AbstractController
) {
}
#[Route('/admin/disposition/create/{uuid}', name: 'app_admin_disposition_create')]
#[Route('/admin/application/dispose/{uuid}', name: 'app_admin_application_dispose')]
#[IsGranted('ROLE_ADMINISTRATIVE')]
#[IsGranted('DISPOSE', subject: 'application')]
public function index(Application $application): Response
{
$disposition = new Disposition($application);
@@ -0,0 +1,39 @@
<?php
namespace App\Controller\Admin\Application;
use App\Entity\Application;
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;
class RejectController extends AbstractController
{
public function __construct(
private readonly EntityManagerInterface $entityManager,
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
{
$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(),
]);
}
}
@@ -2,27 +2,34 @@
namespace App\Controller\Admin\Assignment;
use App\Controller\Traits\ReturnUrlTrait;
use App\Entity\Assignment;
use App\Repository\ApplicationRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
class DetailController extends AbstractController
{
use ReturnUrlTrait;
public function __construct(private readonly ApplicationRepository $applicationRepository)
{}
#[Route('/admin/assignment/detail/{uuid}', name: 'app_admin_assignment_detail')]
#[IsGranted('ROLE_ADMINISTRATIVE')]
public function index(Assignment $assignment): Response
public function index(Assignment $assignment, Request $request): Response
{
$applications = $this->applicationRepository->findBy(['assignment' => $assignment]);
$applications = $this->applicationRepository->findBy([
'assignment' => $assignment,
]);
return $this->render('admin/assignment/detail.html.twig', [
'assignment' => $assignment,
'applications' => $applications,
'returnUrl' => $this->getReturnUrl($request, 'app_admin_assignment_index'),
]);
}
}