-
-
Notifications
You must be signed in to change notification settings - Fork 921
Fix route name resolving with subresources #1110
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
@@ -32,5 +32,5 @@ | |||
* | |||
* @return string | |||
*/ | |||
public function getRouteName(string $resourceClass, $operationType): string; | |||
public function getRouteName(string $resourceClass, $operationType, array $context = []): string; |
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.
I think that this is a breaking change. Should I avoid changing this interface? I need more informations when retrieving the route name for a subresource because multiple routes may find a wrong match on the same resource class. It has to take into consideration the subresource tree. See isSameSubresource
in RouteNameResolver
.
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.
Yes, this is a BC break.
* @ApiResource | ||
* @ORM\Entity | ||
*/ | ||
class DummyTour |
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.
I suggest renaming this to DummyProduct
(Tour
is from my own project), since the offers
property is defined by https://schema.org/offers
e962113
to
df0c44d
Compare
I've done some dirty fix to avoid breaking, let me know your thoughts or if you have another idea on how to do this.
|
Hehe... We can ignore the PHPstan error for now. 😄 |
460e2b7
to
59afc11
Compare
ping @dunglas is also good to merge if you agree with the routename patch! |
@@ -51,7 +51,7 @@ public function getRouteName(string $resourceClass, $operationType): string | |||
// do nothing | |||
} | |||
|
|||
$routeName = $this->decorated->getRouteName($resourceClass, $operationType); | |||
$routeName = $this->decorated->getRouteName($resourceClass, $operationType, @func_get_arg(2)); |
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 do it like that instead https://github.com/symfony/symfony/blob/3.4/src/Symfony/Component/Serializer/Serializer.php#L182-L190
{ | ||
$context = @func_get_arg(2); |
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.
Same here
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 thanks
Also resolves conflicts with existing subresources on a property having the same name
Thanks @soyuka |
Fix route name resolving with subresources
Also resolves conflicts with existing subresources on a property having
the same name
Unit tests don't pass for now, waiting for an answer to the below comment.