I work with symfony2, sonata admin-bundle and mongodb, I just created an interface to add users, how can I send an email when user create on the sonataadmin web interface, I have to override any Sonata-Admin class
UPDATE
public function create($object)
{
parent::create($object);
$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 mailer.
Jorge source
share