I try to send a Swift mail from the commandline using a Symfony command. Though I get the following exception.
Fatal error: Call to undefined method Symfony\Bundle\TwigBundle\Debug\TimedTwigE
ngine::renderView() in ...
A container is added to this class which I got from the command that is made ContainerAwareCommand
The code of the function lookslike this:
private function sendViaEmail($content) {
$message = \Swift_Message::newInstance()
->setSubject('Hello Email')
->setFrom('[email protected]')
->setTo('[email protected]')
->setBody(
$this->container->get('templating')->renderView(
'BatchingBundle:Default:email.html.twig', array('content' => $content)
)
);
$this->get('mailer')->send($message);
}
Update
The line where the exception happens is $this->container->get('templating')->renderView(
As you can see in the code the last line would probably fail aswell as it finally gets there.