-
-
Notifications
You must be signed in to change notification settings - Fork 920
Fallback attributes in the @ApiResource annotation #1788
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
Fallback attributes in the @ApiResource annotation #1788
Conversation
cf73222
to
1e4dbad
Compare
src/Annotation/ApiResource.php
Outdated
/** | ||
* @var string | ||
*/ | ||
private $accessControl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a reference to the PHPStorm plugin issue, so we'll not forget and drop those properties later :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
* @Attribute("shortName", type="string"), | ||
* @Attribute("subresourceOperations", type="array"), | ||
* @Attribute("validationGroups", type="mixed") | ||
* ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FTR I'm using vim and all I see is noise 😈
(it's friday I'm allowed to rage coz I'm a hater)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dear @soyuka,
I encourage you to download a real IDE. Here is the link to PHPStorm: https://www.jetbrains.com/phpstorm/download/.
I hope this could help you to find the truth!
Yours sincerely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More seriously, @Attribute
annotations are needed when using a constructor in your annotation class. The noise here are the private properties.
1e4dbad
to
87edf6c
Compare
87edf6c
to
2cbee1d
Compare
private $routePrefix; | ||
|
||
/** | ||
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not having it on the class level since it's on every property?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we may introduce other properties for valid reasons later.
Thanks @meyerbaptiste |
I wonder if these could be fully documented in the docs? |
Yes it will be @bendavies, it's on my todo list 😉 |
Didn't see this earlier, but I also think it's bad, as the attributes were arbitrary keys we used, and many of them were specific to the Symfony integration. But now they've been elevated to a more important status. |
This PR adds the ability to configure resource attributes directly at the first level of the
@ApiResource
annotation. This improves the DX by adding autocompletion on annotation properties with modern IDEs.Attribute keys are normally in snake_case but we use lowerCamelCase at the first level of the
@ApiResource
annotation. So I made the choice to define them also in lowerCamelCase here but they are then normalized to snake_case.About private properties (see the second commit), they are "virtual" because of this issue: Haehnchen/idea-php-annotation-plugin#112. I don't like that, so if you have a better idea, just tell me.
In the same way, what about priorities? For example, actually:
validationGroups={"foo"}, attributes={"validation_groups"={"bar"}}
=['bar']
.Are you agree? Or do you want
['foo']
or['foo', 'bar']
instead?