I have a service method that I call by a MessageHandler and by a Controller Action:
class ReceiptService
{
public function myMethod()
{
// ...
$html = $this->twig->render('folder/file.html.twig', []);
// ...
}
}
In my twig template, I call some CSS files:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>My title</title>
<link rel="stylesheet" href="css/PDF/file.css">
</head>
<body>
<!-- ... -->
</body>
</html>
When I use the Controller Action, the twig template is able to find my CSS files. But when it's the MessageHandler that calls it, it does not find it unless I put public/
before each href, e.G.
<link rel="stylesheet" href="public/css/PDF/file.css">`
I tried using {{ asset() }}
without success.
Would you know why and how to solve this?