symfony/symfony — pull request #2572 by Seldaek (2011-11-06 12:56:12+00:00)
Title: [EventDispatcher] Add reference to the EventDispatcher on the Event

Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: -

I don't like registering event listeners unless they are really used, it seems wasteful. So I tend to register listeners for the response event in other listeners, only when they will be required. @stof has [brought to my attention](https://github.com/nelmio/NelmioCorsBundle/commit/fb243ace83c55280d8a7841a0fbaf22a4e947600#commitcomment-696467) that this may cause issues in Silex or any other situation where event listeners are not lazy loaded, since it creates a circular reference in that case.

With this PR, avoiding the circular reference is possible, without bloating the response listener with unnecessary "do I need to do anything?" code.