[英]Attempted to call an undefined method named “get” of class “MailController”
I want to sent an email with swiftmailer this is my function in my mailController.php 我想用swiftmailer发送电子邮件,这是我的mailController.php中的函数
public function newMail(Mail $mail){
$message = \Swift_Message::newInstance()
->setSubject('Accusé de réception')
->setFrom('hela.mejri@esprit.tn')
->setTo($mail->getEmail())
;
$this->get('mailer')->send($message);
}
error : Attempted to call an undefined method named "get" of class "UserBundle\\Controller\\MailController". 错误:试图调用类“ UserBundle \\ Controller \\ MailController”的名为“ get”的未定义方法。
Add the use statement atop your controller class and then modify your controller to extend it: 在您的控制器类上添加use语句,然后修改您的控制器以对其进行扩展:
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class YourController extends Controller
{
// ...
}
That's it! 而已! You now have access to methods like $this->get()
or $this->render()
and many others. 现在,您可以访问$this->get()
或$this->render()
等方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.