WIP: Refactor application rejecting process
This commit is contained in:
@@ -24,7 +24,7 @@ class IndexController extends AbstractController
|
|||||||
{
|
{
|
||||||
$query = $this
|
$query = $this
|
||||||
->applicationRepository
|
->applicationRepository
|
||||||
->getListQuery()
|
->getPendingQuery()
|
||||||
;
|
;
|
||||||
|
|
||||||
$pagination = $this->paginator->paginate(
|
$pagination = $this->paginator->paginate(
|
||||||
|
|||||||
@@ -3,17 +3,21 @@
|
|||||||
namespace App\Controller\Admin\Application;
|
namespace App\Controller\Admin\Application;
|
||||||
|
|
||||||
use App\Entity\Application;
|
use App\Entity\Application;
|
||||||
|
use App\Event\ApplicationRejectedEvent;
|
||||||
|
use App\Model\ApplicationCheckDto;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||||
|
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
|
||||||
|
|
||||||
class RejectController extends AbstractController
|
class RejectController extends AbstractController
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly EntityManagerInterface $entityManager,
|
private readonly EntityManagerInterface $entityManager,
|
||||||
|
private readonly EventDispatcherInterface $eventDispatcher,
|
||||||
private readonly LoggerInterface $logger
|
private readonly LoggerInterface $logger
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
@@ -23,6 +27,9 @@ class RejectController extends AbstractController
|
|||||||
#[IsGranted('REJECT', subject: 'application')]
|
#[IsGranted('REJECT', subject: 'application')]
|
||||||
public function index(Application $application): Response
|
public function index(Application $application): Response
|
||||||
{
|
{
|
||||||
|
$applicationCheckDto = new ApplicationCheckDto($application);
|
||||||
|
$this->eventDispatcher->dispatch(new ApplicationRejectedEvent($applicationCheckDto), ApplicationRejectedEvent::NAME);
|
||||||
|
|
||||||
$application->setStatus(Application::STATUS_REJECTED);
|
$application->setStatus(Application::STATUS_REJECTED);
|
||||||
|
|
||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Event;
|
||||||
|
|
||||||
|
use App\Entity\Application;
|
||||||
|
use App\Model\ApplicationCheckDto;
|
||||||
|
use Symfony\Contracts\EventDispatcher\Event;
|
||||||
|
|
||||||
|
class ApplicationRejectedEvent extends Event
|
||||||
|
{
|
||||||
|
public const NAME = 'application.rejected';
|
||||||
|
|
||||||
|
private Application $application;
|
||||||
|
private ?string $comment;
|
||||||
|
|
||||||
|
public function __construct(ApplicationCheckDto $applicationCheckDto)
|
||||||
|
{
|
||||||
|
$this->application = $applicationCheckDto->getApplication();
|
||||||
|
$this->comment = $applicationCheckDto->getComment();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getApplication(): Application
|
||||||
|
{
|
||||||
|
return $this->application;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getComment(): ?string
|
||||||
|
{
|
||||||
|
return $this->comment;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Model;
|
||||||
|
|
||||||
|
use App\Entity\Application;
|
||||||
|
|
||||||
|
class ApplicationCheckDto
|
||||||
|
{
|
||||||
|
private Application $application;
|
||||||
|
private ?string $comment = null;
|
||||||
|
|
||||||
|
public function __construct(Application $application)
|
||||||
|
{
|
||||||
|
$this->application = $application;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getApplication(): Application
|
||||||
|
{
|
||||||
|
return $this->application;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getComment(): ?string
|
||||||
|
{
|
||||||
|
return $this->comment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setComment(?string $comment): static
|
||||||
|
{
|
||||||
|
$this->comment = $comment;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23,7 +23,7 @@ class ApplicationRepository extends ServiceEntityRepository
|
|||||||
parent::__construct($registry, Application::class);
|
parent::__construct($registry, Application::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getListQuery(): Query
|
public function getPendingQuery(): Query
|
||||||
{
|
{
|
||||||
$qb = $this->createQueryBuilder('application');
|
$qb = $this->createQueryBuilder('application');
|
||||||
|
|
||||||
@@ -33,6 +33,8 @@ class ApplicationRepository extends ServiceEntityRepository
|
|||||||
->innerJoin('assignment.destination', 'destination')
|
->innerJoin('assignment.destination', 'destination')
|
||||||
->innerJoin('assignment.jobProfile', 'job_profile')
|
->innerJoin('assignment.jobProfile', 'job_profile')
|
||||||
->innerJoin('application.teamer', 'teamer')
|
->innerJoin('application.teamer', 'teamer')
|
||||||
|
->where($qb->expr()->neq('application.status', ':status'))
|
||||||
|
->setParameter('status', Application::STATUS_REJECTED)
|
||||||
->getQuery()
|
->getQuery()
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user