脚本宝典收集整理的这篇文章主要介绍了php – 来自Symfony Command的Swift邮件,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
Fatal error: Call to undefined method Symfony\Bundle\TwigBundle\Debug\TimedTwigE ngine::renderView() in ...
一个容器被添加到这个类中,这是我从ContainerAwareCommand命令中获得的
PRivate function sendViaEmail($content) { $message = \Swift_Message::newInstance() ->setSubject('Hello Email') ->setFrom('123@gmail.COM') ->setTo('123@gmail.com') ->setBody( $this->container->get('templating')->renderView( 'BatchingBundle:Default:email.htML.twig',array('content' => $content) ) ); $this->get('mailer')->send($message); }
更新
发生异常的行是$this-> container-> get(‘templating’) – > renderView(
正如你在代码中看到的那样,最后一行可能会失败,直到它最终到达那里.
namespace Symfony\Bundle\FrameworkBundle\Controller class Controller extends ContainerAware { /** * Returns a rendered view. * * @param string $view The view name * @param array $parameters An array of parameters to pass to the view * * @return string The rendered view */ public function renderView($view,array $parameters = array()) { return $this->container->get('templating')->render($view,$parameters); } }
在那里,您可以看到使用模板服务呈现视图的正确方法.
$this->container->get('templating')->render( 'BatchingBundle:Default:email.html.twig',array('content' => $content) )
以上是脚本宝典为你收集整理的php – 来自Symfony Command的Swift邮件全部内容,希望文章能够帮你解决php – 来自Symfony Command的Swift邮件所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。