Skip to content

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

Merged
merged 5 commits into from
May 23, 2018

Conversation

dunglas
Copy link
Member

@dunglas dunglas commented May 22, 2018

Q A
Bug fix? yes
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets n:a
License MIT
Doc PR n/a

Same as #1788 but for @ApiProperty. Also add support for some missing attributes in @ApiResource.

@dunglas dunglas requested a review from meyerbaptiste May 22, 2018 14:29
/**
* @throws InvalidArgumentException
*/
public function __construct(array $values = [])
Copy link
Contributor

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 ?

Copy link
Member Author

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.

Copy link
Member Author

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.

@@ -20,9 +20,17 @@
*
* @Annotation
* @Target({"METHOD", "PROPERTY"})
* @Attributes(
* @Attribute("fetcheable", type="bool"),
Copy link
Member

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'))) {
Copy link
Member

@meyerbaptiste meyerbaptiste May 22, 2018

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?

Copy link
Member Author

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.

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 😉

Copy link
Member Author

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.

@dunglas dunglas merged commit 4441501 into api-platform:master May 23, 2018
@dunglas dunglas deleted the api-property branch May 23, 2018 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants