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
Accessing original object in lifecycle hook #622
Comments
Currently not, as Only way I can see now (without accessing private props) is to do the diff yourself, by first saving the state in |
That makes sense. Just to add some color to what I'm trying to do in case it's helpful for implementation, I'm basically trying to make the entity observable and only take action on certain kinds of changes: Say I have a user entity:
With an associated EntitySchema object that defines hook the afterUpdate hook. What I'd like to do is allow an observer to be able to see both the original as well as updated in case it only cares about changes to userName but not lastLogin over the course of the unit of work. I'll try the approach you recommended and capture the beginning state in a different hook for the time being. |
Lifecycle hooks are now executed the same way as `EntitySubscriber`s, this means that they will also get the `EventArgs` in the parameters. `EventArgs` now also optionally contain the `ChangeSet` object, so it is possible to get the information about what fields actually changed or access the original entity data. Closes #622
Lifecycle hooks are now executed the same way as `EntitySubscriber`s, this means that they will also get the `EventArgs` in the parameters. `EventArgs` now also optionally contain the `ChangeSet` object, so it is possible to get the information about what fields actually changed or access the original entity data. Closes #622
Lifecycle hooks are now executed the same way as `EntitySubscriber`s, this means that they will also get the `EventArgs` in the parameters. `EventArgs` now also optionally contain the `ChangeSet` object, so it is possible to get the information about what fields actually changed or access the original entity data. Closes #622
Lifecycle hooks are now executed the same way as `EntitySubscriber`s, this means that they will also get the `EventArgs` in the parameters. `EventArgs` now also optionally contain the `ChangeSet` object, so it is possible to get the information about what fields actually changed or access the original entity data. Closes #622
Closing as implemented in v4 via #623, will be part of next alpha. All hooks will get an Theoretically it should be even possible to adjust the payload in |
Lifecycle hooks are now executed the same way as `EntitySubscriber`s, this means that they will also get the `EventArgs` in the parameters. `EventArgs` now also optionally contain the `ChangeSet` object, so it is possible to get the information about what fields actually changed or access the original entity data. Closes #622
Lifecycle hooks are now executed the same way as `EntitySubscriber`s, this means that they will also get the `EventArgs` in the parameters. `EventArgs` now also optionally contain the `ChangeSet` object, so it is possible to get the information about what fields actually changed or access the original entity data. Closes #622
Hello @B4nan . Is it possible to get originalEntity populated?
I also tried to eager load the relationship on Insercao Entity definition, but still no success:
Must I find my Comercial to use its property? |
|
I'd like to conditionally take some actions if certain fields of my entity have been updated and I'm curious if there is any way to gain access to both the original entity as well as the updated entity in the
afterUpdate
lifecycle hook so I can compare fields to see which were updated?The text was updated successfully, but these errors were encountered: