'uuid'])] MailingTemplate $template, Request $request, ): Response { if (true === $template->isDeleted()) { throw $this->createNotFoundException('Die Mailvorlage wurde gelöscht'); } $form = $this->createForm(MailingTemplateType::class, $template); $form->handleRequest($request); // files left over from a template form that was never saved must not end up on this one if (false === $form->isSubmitted()) { $this->attachmentHandler->discardPending(Upload::TYPE_MAILING_TEMPLATE); } /** @var Upload[] $remove */ $remove = $form->has('removeAttachments') ? iterator_to_array($form->get('removeAttachments')->getData() ?? [], false) : []; if ($form->isSubmitted() && $form->isValid()) { if (null !== $error = $this->attachmentHandler->validateTemplateAttachments($template, $remove)) { $form->addError(new FormError($error)); } } if ($form->isSubmitted() && $form->isValid()) { $this->attachmentHandler->saveTemplateAttachments($template, $remove, $this->getAuthenticatedUser()); $this->entityManager->flush(); $this->addFlash('success', 'Die Mailvorlage wurde aktualisiert'); $this->logger->info('Edit mailing template', [ 'mailing_template_id' => $template->getId(), 'mailing_template_name' => $template->getName(), 'attachments' => $template->getAttachments()->count(), 'attachments_removed' => count($remove), ]); return $this->redirectToRoute('app_administrative_system_mailing_template_index'); } return $this->render('administrative/system/mailing_template/edit.html.twig', [ 'form' => $form->createView(), 'template' => $template, 'pending' => $this->attachmentHandler->getPending(Upload::TYPE_MAILING_TEMPLATE), 'placeholders' => TeamerMailingService::PLACEHOLDERS, 'maxAttachmentBytes' => MailingAttachmentHandler::MAX_TOTAL_BYTES, ]); } }