0 votes

Image caption

If I edit a Doctrine 2 entity by hand, I am able to assign more than one lifecycle event to a method. Please see the method "setRecordLastModifiedDateTime" where I have the lifecycle event listeners for prePersist and preUpdate. Using the entity in my application works as desired.

Image caption
In ORM Designer, I am limited to assigning only one lifecycle event at a time to a method. This forces me to manually edit my entity files by hand even after I had used ORM Designer to create the entities and export them.

Can you add the ability to assign multiple lifecycle events to a single method in a future release of ORM Designer? It would be a boost to my productivity with ORM Designer. Thanks.

in Solved by (380 points)
recategorized by

1 Answer

0 votes
Best answer

It is possible to add such functionality. However we need to be sure this is supported by Doctrine2 before we add this. Is there an official Doctrine2 documentation for this? Please send me a link and we will add this function to the application.

by Skipper developer (74.8k points)
selected by

I checked through the Doctrine documentation again and they do not explicitly show assigning multiple lifecycle events to a single callback. So, I took the question to the doctrine-user group on Google:

https://groups.google.com/forum/#!topic/doctrine-user/76_B1GEJLl4

Like I said, the functionality that I am describing DOES work in my own usage and it seems confirmed by at least one other user in the group. I don't know how to ask the Doctrine people to document this feature.

Sorry for the delayed reply.

I took a closer look at the issue and the functionality you need is already implemented. There is just small glitch at the merging of the methods: if you generate more callbacks at once, they will be separated like this:
http://i.imgur.com/07BK5y9.png

However if you define first callback in the model, then export, then you define other callback and export again, they will be merged as required:
http://i.imgur.com/edYHlSl.png

Also if you merge the annotations by hand and import the project again, ORM Designer will not change them after the next export.

We will prepare fix for this, but I thought the workaround might be useful in the meantime. The fix will be released in one of the next versions.