Whats the difference between postUpdate and postPersist events in Doctrine's event listener class? In my understanding, persist has to be done for both update and insertion. whats the benefit of having postUpdate then when one can handle this in the postPersist event?
Because you should handle some logic only on update for example. And from doctrine's docs:
postPersist - The postPersist event occurs for an entity after the entity has been made persistent. It will be invoked after the database insert operations. Generated primary key values are available in the postPersist event.
postUpdate - The postUpdate event occurs after the database update operations to entity data. It is not called for a DQL UPDATE statement.
Do you see the difference now? The postPersist
event is launched only after INSERT
operations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With