draftHandler = $draftHandler; $this->mailingService = $mailingService; $this->attachmentHandler = $attachmentHandler; $this->teamerMailingService = $teamerMailingService; $this->mailBodyRenderer = $mailBodyRenderer; } /** * The form over the draft: a GET shows the parked wording, a POST carries the current one. * Assignments and template stay what the draft says, the form has no fields for them. */ protected function createMailingForm(Request $request, ?AssignmentMailingDto $mailingDto = null): FormInterface { $form = $this->createForm(AssignmentMailingType::class, $mailingDto ?? $this->draftHandler->getDraft()); $form->handleRequest($request); return $form; } /** * What the composing user would receive, see the teamer mailing's renderPreview(). * * @return array{subject: string, bodyHtml: string} */ protected function renderPreview(AssignmentMailingDto $mailingDto): array { $values = $this->teamerMailingService->placeholderValuesForUser($this->getAuthenticatedUser()); return [ 'subject' => $this->teamerMailingService->render($mailingDto->getSubject(), $values), 'bodyHtml' => $this->mailBodyRenderer->render($mailingDto->getMessage(), $values), ]; } /** * For administrative/assignment_mailing/_assignments.html.twig. */ protected function assignmentsContext(AssignmentMailingDto $mailingDto): array { return [ 'mailingDto' => $mailingDto, 'recipients' => $this->mailingService->resolveRecipients($mailingDto), 'addForm' => $this->createForm(AssignmentMailingAddType::class)->createView(), ]; } /** * For administrative/assignment_mailing/_attachments.html.twig. */ protected function attachmentsContext(AssignmentMailingDto $mailingDto): array { return [ 'mailingDto' => $mailingDto, 'pending' => $this->attachmentHandler->getPending(Upload::TYPE_MAILING_ATTACHMENT), 'maxAttachmentBytes' => MailingAttachmentHandler::MAX_TOTAL_BYTES, ]; } }