0 votes

Image caption

I am using Doctrine 2.

I would like to have a method called setRecordLastModifiedDateTime executed during these two lifecycle events:

prePersist
preUpdate

How do I do that? It seems that I can only assign one lifecycle event to a method.

in Solved by (380 points)
recategorized by

Thank you for your question. Do you have any link to Doctrine2 documentation where this behavior is described? Is this feature supported by D2?

Thanks for the quick reply, Ludek. Your reply forced me to review the Doctrine 2 documentation and I think the solution is to not assign the two lifecycle callbacks to the same method, so please disregard my question. It seems the solution is to assign each callback to one method that in turn wraps calls those methods that I need to for any of the lifecycle events.

You're welcome. I'm glad I helped you to solved it.

1 Answer

0 votes
Best answer

I moved it to answer so also other users can find it:

Thanks for the quick reply, Ludek. Your reply forced me to review the Doctrine 2 documentation and I think the solution is to not assign the two lifecycle callbacks to the same method, so please disregard my question. It seems the solution is to assign each callback to one method that in turn wraps calls those methods that I need to for any of the lifecycle events.

by Skipper developer (138k points)