mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
DDC-1825: generate entities with traits #2297
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (May 18, 2012).
Originally assigned to: @Ocramius on GitHub.
Jira issue originally created by user lunetics:
When a trait with included setters and getters is used and generate entities is called, doctrine add another set of getters and setters to the "main" entity where the trait is used.
@doctrinebot commented on GitHub (May 1, 2014):
Comment created by lsv20:
Now when I run php app/console doctrine:generate:entities it copies everything from the trait and into the entity, so the entity now looks like
And ofcourse invalidates the entity because it now has two methods of the getCreated and two of private $created
@doctrinebot commented on GitHub (Dec 1, 2014):
Comment created by wilgert:
Unfortunately I am also suffering from this bug. Is there anything I can do to help resolve it?
@doctrinebot commented on GitHub (Mar 24, 2015):
Comment created by ludwig.ruderstaller:
Same here - i think an easy fix would be to introduce an additional parameter, which if set, ignores all traits.
@henrypenny commented on GitHub (Mar 7, 2016):
I've been successfully using traits with doctrine and symfony 2 in this way without the problem mentioned. ( I have not tried to use Doctrine in this way outside of Symfony though )
The only difference I can see is that I use the Entity annotation on the trait:
Process:
traittoclassapp/console doctrine:generate:entities AppBundle:Locatableclassback totraituseing class e.g. AppBundle:Regionapp/console doctrine:generate:entities AppBundle:Regionmakes no changes toRegionapp/console doctrine:migrations:diffetc... produces the new fields on any classes using thetraitThe only complaint I have is that I can't use
doctrine:generate:entitieson the trait without changing thetraitkeyword temporarily.@Ocramius commented on GitHub (Mar 7, 2016):
Traits are well beyond the scope of the entity generator.
There is no need to generate entities on existing classes anyway (if you do it just for the getter/setters, there are other development tools for that).
Closing as
Won't Fix@henrypenny commented on GitHub (Mar 7, 2016):
Can you reopen this? My current workflow is extremely powerful and I'm using it all the time.
I can't imagine that allowing the generator to accept a trait would be a big change.
@Ocramius commented on GitHub (Mar 7, 2016):
@henrypenny generating getters/setters is out of the scope of the entity generator in general: the fact that symfony taught you that has nothing to do with what it was intended for (importing legacy DB schemas as entities)