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\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],
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user