mail-rss/src/Controller/MailController.php

59 lines
1.5 KiB
PHP

<?php
namespace App\Controller;
use App\Entity\Mail;
use App\Entity\Mailing;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class MailController extends AbstractController
{
/**
* @Route("/mail/{mailing}/{id}/show", name="mail_show")
*/
public function show(string $mailing, Mail $mail): Response
{
if ($mail->getMailing()->getId() !== $mailing) {
throw $this->createNotFoundException();
}
return $this->render('mail/show.html.twig', [
'mail' => $mail,
]);
}
/**
* @Route("/mail/{mailing}/{id}/html", name="mail_html")
*/
public function html(string $mailing, Mail $mail): Response
{
if ($mail->getMailing()->getId() !== $mailing) {
throw $this->createNotFoundException();
}
return $this->render('mail/html.html.twig', [
'mail' => $mail,
]);
}
/**
* @Route("/mail/{mailing}/{id}/text", name="mail_text")
*/
public function text(string $mailing, Mail $mail): Response
{
if ($mail->getMailing()->getId() !== $mailing) {
throw $this->createNotFoundException();
}
$response = $this->render('mail/text.html.twig', [
'mail' => $mail,
]);
$response->headers->set('Content-Type', 'text/plain');
return $response;
}
}