-
Notifications
You must be signed in to change notification settings - Fork 380
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
Blameable listener need to use managed version of user in case of entity manager is cleared #373
Comments
Has anyone experienced this particular problem and successfully solved it? What should I exactly do in onClear listener? @sam0delkin ? |
@BazylPL for a workaround i used the following: $container->get('stof_doctrine_extensions.listener.blameable')->setUserValue($user); note, that |
@sam0delkin where do you set that user value? Did you created some listener onClear and injected the container? |
@BazylPL well, i'm using this on the queue consumer... So, maybe you're using this for different purposes. But yes, i think you can create some listener that listen to onClear event, and change the user in all places you can, as well, as you should change the token: $token = new UsernamePasswordToken($user, '', 'default');
$tokenStorage->setToken($token); |
@BazylPL but want to underline that it's a hack and workaround 😄 |
Yeah, I know :( We need to go deeper :) |
@BazylPL well, the best solution I see here is to:
Another options are:
So, with thought above, i think this issue should be closed and addresed to some other repo.... |
Assume i have an entity:
and somehwere in code:
Exception:
Possible solution is to listen for
onClear
Doctrine event and do a$em->getReference()
to get a managed version of the user.Thanks in advance!
The text was updated successfully, but these errors were encountered: