-
-
Notifications
You must be signed in to change notification settings - Fork 876
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
fix(doctrine): resource_class from context instead of entity class #6592
base: 3.3
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,7 @@ private function handleLinks(Builder $aggregationBuilder, array $identifiers, ar | |
return; | ||
} | ||
|
||
$links = $this->getLinks($resourceClass, $operation, $context); | ||
$links = $this->getLinks($context['resource_class'] ?? $resourceClass, $operation, $context); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if |
||
|
||
if (!$links) { | ||
return; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,7 @@ private function handleLinks(QueryBuilder $queryBuilder, array $identifiers, Que | |
$doctrineClassMetadata = $manager->getClassMetadata($entityClass); | ||
$alias = $queryBuilder->getRootAliases()[0]; | ||
|
||
$links = $this->getLinks($entityClass, $operation, $context); | ||
$links = $this->getLinks($context['resource_class'] ?? $entityClass, $operation, $context); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From what I understand the problem occurs only when it's an embed resource? I'm wondering though why this |
||
|
||
if (!$links) { | ||
return; | ||
|
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 functional test with your stateOption? couldn't we get
stateOptions->entityClass
directly instead of using this context value?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.
@soyuka thanks for your reply. The
stateOptions->entityClass
could be null if not applied to an API Resource, thats why i opted for context usage.I've just added a Functional Tests to the Branch.
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.
Question is, do we need the changes to the Persist Process generally? I've just changed it there as well to be consistent and the existing Test did not fail afterwards.
I'm sadly not that deep into API Platform to determine it right now.
For me, it was important to start working with the right Pattern, which always concludes the separation of Entities from View / Logic, but relying on existing Logic as much as Possible. Therefore i opted for the DTO Approach using stateOptions to still use the Doctrine Handler.
As it seems not a lot of people / projects are using the DTO Approach, specially with GraphQL, i would guess the Bug need some further investigation by People with more knowledge into API Platform.
Maybe someone can have a deeper look into this PR and Issue.
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.
IMHO these lines are missing here:
core/src/Doctrine/Orm/State/ItemProvider.php
Lines 51 to 55 in a50e2d0
Then the
entityClass
will be correct