feat: further decouple logic using events
This commit is contained in:
1 parent
3a77697d9d
commit
a1882a4af1
10 files changed
+127
-68
No files matched your search
@@ -8,7 +8,6 @@ use App\Entity\User;
|
||||
use App\Event\FeedbackProvidedEvent;
|
||||
use App\Form\FeedbackType;
|
||||
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 ProvideController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly EventDispatcherInterface $eventDispatcher,
|
||||
private readonly LoggerInterface $logger
|
||||
private readonly EventDispatcherInterface $eventDispatcher
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -32,7 +30,6 @@ class ProvideController extends AbstractController
|
||||
/** @var User $user */
|
||||
$user = $this->getUser();
|
||||
$assignment = $disposition->getAssignment();
|
||||
$destination = $assignment->getDestination();
|
||||
|
||||
if (null !== $disposition->getFeedback()) {
|
||||
$this->addFlash('error', 'Es liegt schon ein Feedback vor.');
|
||||
@@ -63,12 +60,10 @@ class ProvideController extends AbstractController
|
||||
$this->entityManager->persist($feedback);
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->eventDispatcher->dispatch(new FeedbackProvidedEvent($feedback), FeedbackProvidedEvent::NAME);
|
||||
$this->logger->info('Feedback provided', [
|
||||
'feedback_id' => $feedback->getId(),
|
||||
'teamer' => (string) $teamer,
|
||||
'destination' => (string) $destination,
|
||||
]);
|
||||
$this->eventDispatcher->dispatch(
|
||||
new FeedbackProvidedEvent($feedback),
|
||||
FeedbackProvidedEvent::NAME
|
||||
);
|
||||
|
||||
$this->addFlash('success', 'Das Feedback wurde entgegengenommen');
|
||||
|
||||
|
||||
Reference in new issue
Block a user