mail-rss/src/Controller/MailController.php

51 lines
1.4 KiB
PHP
Raw Normal View History

2020-11-11 16:37:07 +01:00
<?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;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
2020-11-11 16:37:07 +01:00
class MailController extends AbstractController
{
/**
* @Route("/mail/{mailing}/{mail}/show", name="mail_show")
* @ParamConverter("mail", options={"mapping": {"mail": "id", "mailing": "mailing"}})
2020-11-11 16:37:07 +01:00
*/
public function show(Mail $mail): Response
2020-11-11 16:37:07 +01:00
{
return $this->render('mail/show.html.twig', [
'mail' => $mail,
]);
}
/**
* @Route("/mail/{mailing}/{mail}/html", name="mail_html")
* @ParamConverter("mail", options={"mapping": {"mail": "id", "mailing": "mailing"}})
2020-11-11 16:37:07 +01:00
*/
public function html(Mail $mail): Response
2020-11-11 16:37:07 +01:00
{
return $this->render('mail/html.html.twig', [
'mail' => $mail,
]);
}
/**
* @Route("/mail/{mailing}/{mail}/text", name="mail_text")
* @ParamConverter("mail", options={"mapping": {"mail": "id", "mailing": "mailing"}})
2020-11-11 16:37:07 +01:00
*/
public function text(Mail $mail): Response
2020-11-11 16:37:07 +01:00
{
$response = $this->render('mail/text.html.twig', [
'mail' => $mail,
]);
$response->headers->set('Content-Type', 'text/plain');
return $response;
}
}