Skip to content
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

"No item route associated with the type" exception using class inheritance #2759

Closed
vincentchalamon opened this issue Apr 24, 2019 · 9 comments
Assignees

Comments

@vincentchalamon
Copy link
Contributor

With class inheritance with ApiResource annotation on the parent (abstract) class, I get a No item route associated with the type... exception on the serialization of a related object through the IriConverter > RouteNameResolver.

PR in progress...

@vincentchalamon vincentchalamon self-assigned this Apr 24, 2019
vincentchalamon added a commit to vincentchalamon/core that referenced this issue Apr 24, 2019
vincentchalamon added a commit to vincentchalamon/core that referenced this issue Apr 24, 2019
vincentchalamon added a commit to vincentchalamon/core that referenced this issue Apr 24, 2019
vincentchalamon added a commit to vincentchalamon/core that referenced this issue Apr 24, 2019
vincentchalamon added a commit to vincentchalamon/core that referenced this issue Apr 24, 2019
vincentchalamon added a commit to vincentchalamon/core that referenced this issue Apr 24, 2019
vincentchalamon added a commit to vincentchalamon/core that referenced this issue Apr 24, 2019
vincentchalamon added a commit to vincentchalamon/core that referenced this issue Apr 24, 2019
vincentchalamon added a commit to vincentchalamon/core that referenced this issue Apr 24, 2019
@Nek-
Copy link
Contributor

Nek- commented Apr 24, 2019

#2714 fix it already isn't it?

@vincentchalamon
Copy link
Contributor Author

@Nek- I though it too, but your PR is about ApiResource inheritance, right? In my case, it's only about routing.

@vincentchalamon
Copy link
Contributor Author

But I agree it's linked

@Nek-
Copy link
Contributor

Nek- commented Apr 24, 2019

@vincentchalamon AFAIK if the problem is fixed at the resource resolver level, it is also in routing, isn't it?

@vincentchalamon
Copy link
Contributor Author

vincentchalamon commented Apr 24, 2019

@Nek- I'm not sure about that, cause the RouteNameResolver compares strictly the resource class with the route resource class.

if ($resourceClass === $currentResourceClass && null !== $operation && (empty($methods) || \in_array('GET', $methods, true))) {

This PR allows to compare using parent class.

@Nek-
Copy link
Contributor

Nek- commented Apr 24, 2019

@vincentchalamon
Copy link
Contributor Author

@Nek- I don't see the link with the RouteNameResolver? Or maybe it's the missing point in your PR: to call the ResourceClassResolver from the IriConverter before any call to the RouteNameConverter to be sure to handle the right resourceClass (i.e.: AbstractUser instead of InternalUser in my PR behat tests). WDYT?

@Nek-
Copy link
Contributor

Nek- commented Apr 26, 2019

You're adding resource guess in the route name resolver because it's broken for your case. My PR fixes your case but unfortunately, there's still a bad usage in the AbstractItemNoramlizer after my commits. I took your tests and managed to make them pass with simple modifications using my modifications on the ResourceClassResolver.

I really think managing resource in only one place is the best.

Please see and comment if you need to: 6dcaee0

@teohhanhui
Copy link
Contributor

Should be fixed by #2797. Please verify.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants