Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Todo EVent Subscriber
namespace App\EventSubscribers;
use App\Entity\Todo;
use Doctrine\Common\EventSubscriber;
use Doctrine\ORM\Events;
use Doctrine\Common\Persistence\Event\LifecycleEventArgs;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Mime\Email;
class TodoSubscriber implements EventSubscriber {
* @var MailerInterface
private $mailer;
public function __construct(MailerInterface $mailer)
$this->mailer = $mailer;
public function getSubscribedEvents()
return [
public function postUpdate(LifecycleEventArgs $args)
public function postPersist(LifecycleEventArgs $args)
public function index(LifecycleEventArgs $args)
$entity = $args->getObject();
// perhaps you only want to act on some "Product" entity
if (!$entity instanceof Todo) {
// todo send email to assigned user
// $entityManager = $args->getObjectManager();
$mail = new Email();
->subject('Todo is changed or created')
// dd('Todo is gemaakt of gewijzigd');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.