-
-
Notifications
You must be signed in to change notification settings - Fork 963
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trait injected ApiProperty Attribute gets ignored in STI Entity extending Classes #2043
Comments
I'm using traits to do a Timestampabletrait on a project with the #[ApiProperty(...)] attribute in the traits and it's working well. The only difference is I'm not using the writable: false property. You can try to clear symfony cache with the
If it doesn't work, perhaps the problem is located on the ApiPlatform side especifically when using the writable property. |
Thanks for your reply. In my example for Entity |
It seem's API Platform doesn't officially support entity inheritance, see issues : There is a lot more issues related to inheritance. Pros :
Cons :
|
API Platform version(s) affected: 2.6.5 (api-platform/core)
Description
To reflect different kinds of people types in my application I have decided to go with doctrines single table inheritance (STI) feature to build my entities. These entities all share the fact that they are timestampable via a trait that gets injected in the parent class
Person
. I have this class structure (simplified) for my entities:As you can see I have set the two properties
$createdAt
and$updatedAt
as non-writable since it wouldn't make any sense to update them via API call.This is working fine when writing
Item
ressource entries, but for bothGiver
andDonnee
ressourcescreatedAt
could be set via API.If I move the trait injection from the parent class
Person
into the two subclasses it works as expected (but again won't make too much sense).So not sure if this is really a bug or just a misunderstanding of concepts on my end. Therefore, any hint would be appreciated.
Thank you!
The text was updated successfully, but these errors were encountered: