我正在使用 symfony2、sonata admin-bundle 和 mongodb,我刚刚制作了一个添加用户的界面,当用户在 sonataadmin 的 Web 界面上按“创建”时,如何发送电子邮件,我必须覆盖 Sonata-Admin 的任何类?
UPDATE
//~/UserAdmin.php
public function create($object)
{
parent::create($object);
// send welcome email to new user
$message = \Swift_Message::newInstance()
->setSubject('LOL')
->setFrom('[email protected] /cdn-cgi/l/email-protection')
->setTo('[email protected] /cdn-cgi/l/email-protection')
->setBody('dummy message')
;
$this->getConfigurationPool()->getContainer()->get('mailer')->send($message);
}
我不得不使用$this->getConfigurationPool()->getContainer()->
获取容器和邮件。
您可能想要覆盖create管理类中的方法...
用户管理类:
public function create($object)
{
parent::create($object);
// send welcome email to new user
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)