Sonata Admin: send an email after verification

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

//~/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 mailer.

+4
source share
1 answer

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
}
+3
source

Source: https://habr.com/ru/post/1527945/


All Articles