WIP: Refactor application rejecting process

This commit is contained in:
Björn Fromme
2023-10-18 19:04:06 +02:00
parent 40d4edbf96
commit d42da03a8f
5 changed files with 75 additions and 2 deletions
@@ -24,7 +24,7 @@ class IndexController extends AbstractController
{
$query = $this
->applicationRepository
->getListQuery()
->getPendingQuery()
;
$pagination = $this->paginator->paginate(
@@ -3,17 +3,21 @@
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
) {
}
@@ -23,6 +27,9 @@ class RejectController extends AbstractController
#[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();