+3 votes

ORMD 2.3.3.860, MVC: Symfony2, ORM: Doctrine2

We have a Timestampable behavior that we include via a trait. The lifecycle callbacks are included in ORM Designer, however a new empty method is generated every time by the export with the defined lifecycle callback annotation "@ORM\PrePersist".

It would be great if the annotation parser would consider traits, too, and therefore deduct that there is already such a method with the correct annotation that is available to the class.

I can provide a minimal test case if needed.

in Feature Request by (3.6k points)

1 Answer

+2 votes
Best answer

At this point ORM Designer does not support traits. We will definitely add them in the future, but so far it seems it will be necessary to make larger changes in the parsers for this, so it might take some time before we can implement it.

If you can provide the test case, it would be very helpful.

by Skipper developer (74.8k points)
selected by

Test case download

It does not have a complete project setup and no autoloader, so maybe the trait cannot be evaluated correctly. But this is the way we have it in our project with all the Symfony2 framework components around it. I can add Symfony Standard Edition if you need it.

Thanks for the files. We will have a look at it.

This feature is really important to us. I am wondering as if for a first step in making this work it would help to have the ability to mark entities to be exported as either a class or trait. Even if it wasn't possible at first to link the traits to other entities within Skipper, at least it would be possible to design, maintain and export them. They would linger in the region independently at first. Since they're easily added within the class by using "use TimestampableTrait;" which is code Skipper doesn't replace there would be a basis for being able to use them.

Even better would be if there was a "Trait" tab (maybe you could integrate it into Inheritance), all one would really need to do is assign the trait to an entity, there are no other options required and the export would really just result into the "use" line being added to the class. This way it could be visually integrated into the map as well.

The problem right now is, if one uses Skipper to define the traits, exports the classes, changes the class to trait and re-exports, Skipper will convert it back to a class plus keep all the trait stuff around as junk. So my proposal for the first step to at least being able to define export as trait would at least help keeping everything in sync.

My workaround is to add an empty method, eg "prePresist" with type "PrePersist". Skipper will add @ORM\HasLifecycleCallbacks.
A "Force HasLifecycleCallbacks" checkbox inside entity options would be great.