[Solved] lifecycle callbacks

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

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.

commented Mar 29, 2014 by ludek.vodicka Skipper developer (140,450 points)

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

commented Mar 29, 2014 by mdichirico (380 points)

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.

commented Mar 29, 2014 by ludek.vodicka Skipper developer (140,450 points)

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

1 Answer

0 votes
answered Mar 29, 2014 by ludek.vodicka Skipper developer (140,450 points)
 
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.

...