-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Circular reference when ingecting validator or sec-context and tagging doctrine onFlush event #1111
Comments
This is not specific to FOSUserBundle. It would be the same for any user provider using Doctrine: if you inject Doctrine in the user provider which is then injected in the security context, you cannot inject the security context into Doctrine again. |
Yes, if injecting or (using factory to get) entity_manager directly, but this may be solved by using lazy service "doctrine" and getting manager from it when real call required, or implement another lazy service using ObjectManagerDecorator from Doctrine2.4. Currently I have to inject service container in all services that need to use doctrine onFlush event, this is really bad and caused lot of troubles. And looks like this is a problem not only for me |
Got same problem injecting Twig. Is there any solution to avoid Circular reference exception and not to include service container? |
Not related to this bundle. |
And btw, this should be fixed by #1615 as we don't inject the user manager in the validator anymore (we only inject the canonical fields updater) |
With FOSUserBundle its unable to create any event listener that requires validator or security-context and subscribed on doctrine onFlush event - you'll get exception
example services:
Only Symfony Standard 2.2 + FOSUserBundle (either 1.3.1 or current master) required to reproduce. Full code without vendors https://docs.google.com/file/d/0B1Q55deL45peWHc1dlFfbmt5ZkE/edit?usp=sharing .
Same problem http://www.9nit.com/php/injecting-securitycontext-services-into-a-listener-class-in-symfony2-causes-circular-reference-error-39161.html
The text was updated successfully, but these errors were encountered: