feat: additional and updated email notifications
This commit is contained in:
@@ -3,8 +3,11 @@
|
||||
namespace App\EventListener;
|
||||
|
||||
use App\Email\Mailer;
|
||||
use App\Entity\Application;
|
||||
use App\Entity\Upload;
|
||||
use App\Event\ApplicationStatusEvent;
|
||||
use App\Event\DispositionCreatedEvent;
|
||||
use App\Event\DocumentRejectedEvent;
|
||||
use App\Event\DocumentUploadedEvent;
|
||||
use App\Repository\UserRepository;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
@@ -22,9 +25,14 @@ class EmailNotificationSubscriber implements EventSubscriberInterface
|
||||
return [
|
||||
DispositionCreatedEvent::NAME => 'onDispositionCreated',
|
||||
DocumentUploadedEvent::NAME => 'onDocumentUploaded',
|
||||
DocumentRejectedEvent::NAME => 'onDocumentRejected',
|
||||
ApplicationStatusEvent::NAME => 'onApplicationStatus',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify teamer about accepted application
|
||||
*/
|
||||
public function onDispositionCreated(DispositionCreatedEvent $event): void
|
||||
{
|
||||
$disposition = $event->getDisposition();
|
||||
@@ -39,6 +47,9 @@ class EmailNotificationSubscriber implements EventSubscriberInterface
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify managers about uploaded documents
|
||||
*/
|
||||
public function onDocumentUploaded(DocumentUploadedEvent $event): void
|
||||
{
|
||||
$document = $event->getDocument();
|
||||
@@ -67,4 +78,52 @@ class EmailNotificationSubscriber implements EventSubscriberInterface
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify teamer about rejected document
|
||||
*/
|
||||
public function onDocumentRejected(DocumentRejectedEvent $event): void
|
||||
{
|
||||
$document = $event->getDocument();
|
||||
$disposition = $document->getDisposition();
|
||||
$teamer = $disposition->getTeamer();
|
||||
|
||||
$documentTypeLabel = match ($document->getType()) {
|
||||
Upload::TYPE_CONTRACT => 'dein Honorarvertrag',
|
||||
Upload::TYPE_INVOICE => 'deine Honorarnote',
|
||||
default => 'Dokument '.$document->getOriginalFilename(),
|
||||
};
|
||||
|
||||
$this->mailer->createAndSendEmail([
|
||||
'disposition' => $disposition,
|
||||
'documentTypeLabel' => $documentTypeLabel,
|
||||
'comment' => $event->getComment(),
|
||||
], [
|
||||
'to' => $teamer->getCommunication()->getEmail(),
|
||||
'subject' => ucfirst($documentTypeLabel).' wurde abgelehnt',
|
||||
'template' => 'email/document_rejected.html.twig',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify teamer about rejected application
|
||||
*/
|
||||
public function onApplicationStatus(ApplicationStatusEvent $event): void
|
||||
{
|
||||
$application = $event->getApplication();
|
||||
|
||||
if (Application::STATUS_REJECTED !== $application->getStatus()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$teamer = $application->getTeamer();
|
||||
|
||||
$this->mailer->createAndSendEmail([
|
||||
'appplication' => $application,
|
||||
], [
|
||||
'to' => $teamer->getCommunication()->getEmail(),
|
||||
'subject' => 'Deine Bewerbung wurde abgelehnt',
|
||||
'template' => 'email/application_rejected.html.twig',
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user