Sonata Admin:验证后发送电子邮件(Sonata Admin: send email after validation)

编程入门 行业动态 更新时间:2024-10-17 19:29:14
Sonata Admin:验证后发送电子邮件(Sonata Admin: send email after validation)

我正在使用symfony2,sonata admin-bundle和mongodb,我只是创建了一个添加用户的界面,当用户在sonataadmin的web界面上按下create时如何发送电子邮件,我必须覆盖任何类的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('no-reply@dummy.com') ->setTo('dummy@dummy.com') ->setBody('dummy message') ; $this->getConfigurationPool()->getContainer()->get('mailer')->send($message); }

我不得不使用$this->getConfigurationPool()->getContainer()->来获取容器和邮件程序。

I am working with symfony2, sonata admin-bundle and mongodb, i just made an interface to add users, how can i send an email when user press create on sonataadmin's web interface, i have to override any class of 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('no-reply@dummy.com') ->setTo('dummy@dummy.com') ->setBody('dummy message') ; $this->getConfigurationPool()->getContainer()->get('mailer')->send($message); }

I had to use $this->getConfigurationPool()->getContainer()-> to get the container and the mailer.

最满意答案

您可能想要覆盖admin类中的create方法...

UserAdmin类:

public function create($object) { parent::create($object); // send welcome email to new user }

You probably want to override the create method in the admin class...

UserAdmin class:

public function create($object) { parent::create($object); // send welcome email to new user }

更多推荐

本文发布于:2023-07-25 05:44:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1256812.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:发送电子邮件   Admin   Sonata   validation   email

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!