I have an action that allows a client to view system emails and I want to send a text/plain
header for text versions of emails.
I tried to execute the Symfony docs: Requests and Responses in Symfony section . However, my controller sends a text/html
content type no matter what I do.
This is my action:
function showAction($action = null, $format = null){ $locale = $this->get('session')->getLocale(); $format = $this->getRequest()->get("format"); $format = isset($format) ? $format : 'html'; if ($format === 'text'){ $response = new Response(); $response->headers->set('Content-Type', 'text/plain'); $response->sendHeaders(); } $view = sprintf('MyBundle:Email:%s.%s.%s.twig', $action,$locale,$format); return $this->render($view, array()); }
So, how do I send a text header and where am I mistaken?
source share