feat: attach contract to notification email about new assignment

This commit is contained in:
Björn Fromme
2024-06-19 09:14:45 +02:00
parent 83e0986c9a
commit b03f6e377a
@@ -9,14 +9,17 @@ use App\Event\ApplicationStatusEvent;
use App\Event\DispositionCreatedEvent;
use App\Event\DocumentRejectedEvent;
use App\Event\DocumentUploadedEvent;
use App\Model\EmailAttachmentDto;
use App\Repository\UserRepository;
use App\Service\Pdf\ContractRenderer;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class EmailNotificationSubscriber implements EventSubscriberInterface
{
public function __construct(
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();
$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([
'disposition' => $disposition,
@@ -44,6 +58,7 @@ class EmailNotificationSubscriber implements EventSubscriberInterface
'to' => $teamer->getCommunication()->getEmail(),
'subject' => 'Dein Einsatz wurde angenommen',
'template' => 'email/application_accepted.html.twig',
'attachments' => [$attachment],
]);
}