This repository has been archived by the owner on Jan 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move flush to fire after event triggering.
- Loading branch information
1 parent
ae528a6
commit f7965f8
Showing
1 changed file
with
14 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f7965f8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TomHAnderson why have you moved flush() in f7965f8? Now pre- and post- events are fired before they are actually in db... Maybe better idea would be to add prepersist/preflush events?
f7965f8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The entity is passed by reference to the triggered events. They may change the entity so flush is after events.
f7965f8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm, in my mind, the entity could change in pre- events, so it will be saved changed. But post- events should be after flush - why you'd like to change it twice? Is there any difference between pre-persist and post-persist (in this particular case)?
another thing. Check
EVENT_UPDATE_*
events. TheEVENT_UPDATE_PRE
event will get clear entity (just from DB) before update... And next the entity will be hydrated. So it will be overwritten by hydrator (correct me if I'm wrong)...Nevertheless - if you decide to leave it as is, could you add
EVENT_*_FLUSH
events? Thanks in advance!f7965f8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy where the PRE and POST are now. For your suggestion of _FLUSH events, which I think would be fine, where do you want them, post flush? That seems like a fine place for a new event
Do you mind submitting a PR?
f7965f8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about "post" flush ("pre-flush" is in fact update/create/etc _POST). Sure, I'm going to do PR in a moment.
BTW: I think it would be a good idea to add this change to changelog as BC or at least note it in readme. In fact it broke my code...
f7965f8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just for the record here: see #200.
f7965f8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this.