API Platform version(s) affected: 2.5.3
Description
When filtering on a nested property in ES, we must provide the nested path. Function getNestedFieldPath() in FieldDatatypeTrait.php seems to always return null.
With the example given in your documentation, if we try this filter: /tweets?author.gender=male
author is an object so we enter in this condition:
if (
Type::BUILTIN_TYPE_OBJECT === $type->getBuiltinType()
&& null !== ($nextResourceClass = $type->getClassName())
&& $this->resourceClassResolver->isResourceClass($nextResourceClass)
) {
$nestedPath = $this->getNestedFieldPath($nextResourceClass, implode('.', $properties));
return null === $nestedPath ? $nestedPath : "$currentProperty.$nestedPath";
}
getNestedFieldPath() is called recursively.
gender is the last element of the string, so when we do $currentProperty = array_shift($properties);, $properties is an empty array, so this part returns null:
if (!$properties) {
return null;
}
$nestedPath is null, so this line return null === $nestedPath ? $nestedPath : "$currentProperty.$nestedPath"; returns null
This part seems to be never called:
if (
null !== ($type = $type->getCollectionValueType())
&& Type::BUILTIN_TYPE_OBJECT === $type->getBuiltinType()
&& null !== ($className = $type->getClassName())
&& $this->resourceClassResolver->isResourceClass($className)
) {
return $currentProperty;
}
Thanks
API Platform version(s) affected: 2.5.3
Description
When filtering on a nested property in ES, we must provide the nested path. Function getNestedFieldPath() in FieldDatatypeTrait.php seems to always return null.
With the example given in your documentation, if we try this filter: /tweets?author.gender=male
author is an object so we enter in this condition:
getNestedFieldPath() is called recursively.
gender is the last element of the string, so when we do
$currentProperty = array_shift($properties);, $properties is an empty array, so this part returns null:$nestedPath is null, so this line
return null === $nestedPath ? $nestedPath : "$currentProperty.$nestedPath";returns nullThis part seems to be never called:
Thanks