feat: attach contract to notification email about new assignment
This commit is contained in:
@@ -9,14 +9,17 @@ use App\Event\ApplicationStatusEvent;
|
|||||||
use App\Event\DispositionCreatedEvent;
|
use App\Event\DispositionCreatedEvent;
|
||||||
use App\Event\DocumentRejectedEvent;
|
use App\Event\DocumentRejectedEvent;
|
||||||
use App\Event\DocumentUploadedEvent;
|
use App\Event\DocumentUploadedEvent;
|
||||||
|
use App\Model\EmailAttachmentDto;
|
||||||
use App\Repository\UserRepository;
|
use App\Repository\UserRepository;
|
||||||
|
use App\Service\Pdf\ContractRenderer;
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
|
|
||||||
class EmailNotificationSubscriber implements EventSubscriberInterface
|
class EmailNotificationSubscriber implements EventSubscriberInterface
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly Mailer $mailer,
|
private readonly Mailer $mailer,
|
||||||
private readonly UserRepository $userRepository
|
private readonly UserRepository $userRepository,
|
||||||
|
private readonly ContractRenderer $contractRenderer
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,6 +40,17 @@ class EmailNotificationSubscriber implements EventSubscriberInterface
|
|||||||
{
|
{
|
||||||
$disposition = $event->getDisposition();
|
$disposition = $event->getDisposition();
|
||||||
$teamer = $disposition->getTeamer();
|
$teamer = $disposition->getTeamer();
|
||||||
|
$assignment = $disposition->getAssignment();
|
||||||
|
$destination = $assignment->getDestination();
|
||||||
|
|
||||||
|
$filename = sprintf('Honorarvertrag_%s_%s.pdf', $teamer, $destination);
|
||||||
|
|
||||||
|
$contractPdf = $this->contractRenderer->render($disposition);
|
||||||
|
$attachment = new EmailAttachmentDto(
|
||||||
|
$filename,
|
||||||
|
$contractPdf->Output('S'),
|
||||||
|
'application/pdf'
|
||||||
|
);
|
||||||
|
|
||||||
$this->mailer->createAndSendEmail([
|
$this->mailer->createAndSendEmail([
|
||||||
'disposition' => $disposition,
|
'disposition' => $disposition,
|
||||||
@@ -44,6 +58,7 @@ class EmailNotificationSubscriber implements EventSubscriberInterface
|
|||||||
'to' => $teamer->getCommunication()->getEmail(),
|
'to' => $teamer->getCommunication()->getEmail(),
|
||||||
'subject' => 'Dein Einsatz wurde angenommen',
|
'subject' => 'Dein Einsatz wurde angenommen',
|
||||||
'template' => 'email/application_accepted.html.twig',
|
'template' => 'email/application_accepted.html.twig',
|
||||||
|
'attachments' => [$attachment],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user