1
votes

I just started Symfony2 web app project and I'm stuck at a particular problem:

I have users and I have one subscriber to doctrine events (postUpdate and postPersist) to dispatch custom events, so:

  1. User is updated
  2. Doctrine flushes User
  3. Doctrine subscriber act on postUpdate dispatching 'user.updated' event
  4. Custom event subscriber act on 'user.updated'

Everything goes fine up to that point. What I need to do now is... I need to dispatch 'user.updated_current' if the user modified is current user from within that custom event subscriber (which also subscribes to 'user.updated_current').

Unfortunately 'user.updated_current' event, despite being dispatched, is not handled by my custom event subscriber.

I'm wondering if I actually can dispatch events from within Symfony's event subscriber?

1

1 Answers

2
votes

Just inject event_dispatcher in your subscriber and dispatch your event