Files
myep-team/src/Controller/Admin/ApplicationFormSubmission/SendFollowUpMailController.php
T

49 lines
1.9 KiB
PHP

<?php
namespace App\Controller\Admin\ApplicationFormSubmission;
use App\Email\ApplicationFormSubmissionMailer;
use App\Entity\ApplicationFormSubmission;
use App\Htmx\HxRedirectResponse;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
/**
* Sends the follow-up mail. Never automatic: a reviewer decides when a submission has waited long
* enough, and may send it again after a bounce or a wording fix - the stamp is overwritten.
*
* Unlike the receipt this one is allowed to fail loudly: somebody is watching the response.
*/
class SendFollowUpMailController extends AbstractController
{
public function __construct(private readonly ApplicationFormSubmissionMailer $mailer)
{
}
#[Route('/admin/application-form-submission/send-follow-up/{uuid}', name: 'app_admin_application_form_submission_send_follow_up')]
#[IsGranted('ROLE_TEAM_ADMIN')]
public function index(ApplicationFormSubmission $submission, Request $request): Response
{
if (true === $request->isMethod(Request::METHOD_POST)) {
$this->mailer->sendFollowUp($submission);
$this->addFlash('success', 'Die zweite E-Mail wurde versendet');
return new HxRedirectResponse($this->generateUrl('app_admin_application_form_submission_detail', [
'uuid' => $submission->getUuid(),
'r' => $request->query->get('r'),
]));
}
return $this->render('admin/application_form_submission/modal_send_follow_up.html.twig', [
'submission' => $submission,
// Named in the confirmation so a reviewer sees whether the handout the wording
// promises is actually going out.
'handout' => $this->mailer->findHandout(),
]);
}
}