I have an action that lets the customer preview system email messages and i want to send a text/plain
header for the plaintext versions of the emails.
I tried to follow the Symfony docs : Requests and Responses in Symfony section. However my controller is sending 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 plain header and where am I going wrong?
You need to add $response to render call
return $this->render($view, array(), $response);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With