Home Documentation Download Pricing Buy Now

[Solved] lifecycle callbacks

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.

asked Mar 29, 2014 in Solved by mdichirico (380 points)
recategorized Aug 8, 2014 by Martin Freki Stradej

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.

answered Mar 29, 2014 by ludek.vodicka Skipper developer (140,530 points)
...