Problem
I need to generate CSS file while page is rendering (custom colors for each user). In order to achieve that I made an action to render the file and and put the route as a reference, like that:
public function styleAction()
{
$backgroundColor = $this->getUser()->getCompany()->getBackgroundColor();
if(!$backgroundColor || $backgroundColor =="")
$backgroundColor = '#b5dea2';
$response = new Response();
$response->setContent($this->render('*WHAT_TO_PUT_HERE*:style.css.twig',array('backgroundColor' => $backgroundColor)));
$response->headers->set('Content-Type', 'text/css');
return $response;
}
Route:
css_route:
path: /css/mainStyle
defaults: { _controller: AcmeMainBundle:Default:style }
Question: What to write in place of "WHAT_TO_PUT_HERE" in order to access to the file located under /web/css/style.css.twig.
Resources\views\Default\style.css.twig. Hope this help