-
-
Notifications
You must be signed in to change notification settings - Fork 927
Description
API Platform version(s) affected: 3.1.12
Description
When you use a SearchFilter on a nested property that is a resource and doesn't use "id" as its identifier you get "Can't get a way to read the property "id" in class XXX".
How to reproduce
Have 2 resources A and B, with A containing a B (both simple ApiResources using entityClass=... in my case)
Use an ApiIdentifier in B that is not "id", ie IRIs are /Bs/{someotherfield}.
Add a searchfilter for the B member on A :
#[ApiFilter(SearchFilter::class, properties:['b'])
Possible Solution
Didn't have time to dig into this yet, but it's happening in SearchFilterTrait line 127 :
return $this->getPropertyAccessor()->getValue($item, 'id');
This should probably be replaced so it at least looks for id in the entityClass when present, or even tries to get the ORM to return the correct id(s) without hard coding it.