-
-
Notifications
You must be signed in to change notification settings - Fork 920
Add resource fallback for ApiProperty #1963
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
Conversation
/** | ||
* @throws InvalidArgumentException | ||
*/ | ||
public function __construct(array $values = []) |
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 using a method that we can call the constructor in the class implementing the trait ?
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 it's one more function call and more one level of indirection for no benefit. It's unusual to add a constructor in a trait, but for an annotation like this it's legit. And it's, why this trait is marked @internal
.
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.
@Simperfit do you prefer the strategy in the last commit? It is more explicit, SOLID and don't add an extra call.
src/Annotation/ApiProperty.php
Outdated
@@ -20,9 +20,17 @@ | |||
* | |||
* @Annotation | |||
* @Target({"METHOD", "PROPERTY"}) | |||
* @Attributes( | |||
* @Attribute("fetcheable", type="bool"), |
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.
-fetcheable
+fetchable
@@ -170,7 +170,8 @@ private function joinRelations(QueryBuilder $queryBuilder, QueryNameGeneratorInt | |||
$inAttributes = null; | |||
} | |||
|
|||
if (false === $fetchEager = $propertyMetadata->getAttribute('fetchEager')) { | |||
// Calls to getAttribute are nested for compatibility with the old camelCased notation | |||
if (false === $fetchEager = $propertyMetadata->getAttribute('fetchEager', $propertyMetadata->getAttribute('fetch_eager'))) { |
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.
Should we add a deprecation notice if $propertyMetadata->getAttribute('fetchEager')
is not null?
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.
It would force every user already using this option to change the naming, IMO it is not worth it.
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.
If it's a deprecation, it's not an enforcement 😉
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.
In 3.0 it will. But why not.
Same as #1788 but for
@ApiProperty
. Also add support for some missing attributes in@ApiResource
.