I\'m new of symfony world. I want to use render inside my service, but I got this error
Call to undefined method renderView
I know t
Using constructor dependency injection (tested with Symfony 3.4):
class MyService
{
private $mailer;
private $templating;
public function __construct(\Swift_Mailer $mailer, \Twig_Environment $templating)
{
$this->mailer = $mailer;
$this->templating = $templating;
}
public function sendEmail()
{
$message = $this->templating->render('emails/registration.html.twig');
// ...
}
}
No need to configure arguments.