} // Determine if the next part is not a property of $field_name.
if (!
static::
isCandidateDefinitionProperty($parts[0
],
$candidate_definitions) && !
empty(static::
getAllDataReferencePropertyNames($candidate_definitions))) { // The next path part is neither a delta nor a field property, so it
// must be a field on a targeted resource type. We need to guess the
// intermediate reference property since one was not provided.
//
// For example, the path `uid.name` for a `node--article` resource type
// will be resolved into `uid.entity.name`.
$reference_breadcrumbs[] =
static::
getDataReferencePropertyName($candidate_definitions,
$parts,
$unresolved_path_parts);
} else { // If the property is not a reference property, then all
// remaining parts must be further property specifiers.
if (!
static::
isCandidateDefinitionReferenceProperty($parts[0
],
$candidate_definitions)) { // If a field property is specified on a field with only one property
// defined, throw an error because in the JSON:API output, it does not
// exist. This is because JSON:API elides single-value properties;
// respecting it would leak this Drupalism out.
if (count($candidate_property_names) === 1
) { throw new CacheableBadRequestHttpException($cacheability,
sprintf('Invalid nested filtering. The property `%s`, given in the path `%s`, does not exist. Filter by `%s`, not `%s` (the JSON:API module elides property names from single-property fields).',
$parts[0
],
$external_field_name,
substr($external_field_name, 0,
strlen($external_field_name) -
strlen($parts[0
]) - 1
),
$external_field_name));
}