feat: further decouple logic using events

This commit is contained in:
Björn Fromme committed 2024-07-18 12:42:02 +02:00
1 parent 3a77697d9d
commit a1882a4af1
10 files changed
+127 -68

No files matched your search

@@ -5,7 +5,6 @@ namespace App\Controller\Admin\Application;
use App\Entity\Application;
use App\Event\ApplicationDeletedEvent;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
@@ -16,8 +15,7 @@ class DeleteController extends AbstractController
{
public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly EventDispatcherInterface $eventDispatcher,
private readonly LoggerInterface $logger
private readonly EventDispatcherInterface $eventDispatcher
) {
}
@@ -36,11 +34,6 @@ class DeleteController extends AbstractController
$this->addFlash('success', 'Die Bewerbung wurde gelöscht');
$this->logger->info('Delete application', [
'destination' => (string) $application->getAssignment()->getDestination(),
'teamer' => (string) $application->getTeamer(),
]);
return $this->redirectToRoute('app_administrative_assignment_detail', [
'uuid' => $application->getAssignment()->getUuid(),
]);
@@ -8,7 +8,6 @@ use App\Event\DispositionCreatedEvent;
use App\Form\SpecialAgreementsType;
use App\Htmx\HxRedirectResponse;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@@ -20,8 +19,7 @@ class DisposeController extends AbstractController
{
public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly EventDispatcherInterface $eventDispatcher,
private readonly LoggerInterface $logger
private readonly EventDispatcherInterface $eventDispatcher
) {
}
@@ -45,10 +43,6 @@ class DisposeController extends AbstractController
);
$this->addFlash('success', 'Teamer:in wurde eingeteilt');
$this->logger->info('Create disposition', [
'disposition_id' => $disposition->getId(),
'teamer' => (string) $application->getTeamer(),
]);
$redirectUrl = $this->generateUrl('app_administrative_assignment_detail', [
'uuid' => $application->getAssignment()->getUuid(),
@@ -8,7 +8,6 @@ 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;
@@ -20,8 +19,7 @@ class StatusController extends AbstractController
{
public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly EventDispatcherInterface $eventDispatcher,
private readonly LoggerInterface $logger
private readonly EventDispatcherInterface $eventDispatcher
) {
}
@@ -49,11 +47,6 @@ class StatusController extends AbstractController
);
$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(),
@@ -6,7 +6,6 @@ use App\Entity\Disposition;
use App\Event\DispositionDeletedEvent;
use App\Htmx\HxRedirectResponse;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\HttpFoundation\Request;
@@ -19,8 +18,7 @@ class DeleteController extends AbstractController
{
public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly EventDispatcherInterface $eventDispatcher,
private readonly LoggerInterface $logger
private readonly EventDispatcherInterface $eventDispatcher
) {
}
@@ -44,10 +42,6 @@ class DeleteController extends AbstractController
if ($form->isSubmitted() && $form->isValid()) {
$this->addFlash('success', 'Die Einteilung wurde gelöscht');
$this->logger->info('Delete disposition', [
'disposition_id' => $disposition->getId(),
'teamer' => (string) $disposition->getTeamer(),
]);
$this->entityManager->remove($disposition);
$this->entityManager->flush();