// Make sure that the provided type is compatible with the targeted
// resource.
if (!
in_array($value['type'
],
$target_resource_type_names)) { throw new BadRequestHttpException(sprintf( 'The provided type (%s) does not match the destination resource types (%s).',
$value['type'
],
implode(', ',
$target_resource_type_names) ));
} return new ResourceIdentifier($value['type'
],
$value['id'
],
$value['meta'
] ??
[]);
},
$data['data'
]);
if (!ResourceIdentifier::
areResourceIdentifiersUnique($resource_identifiers)) { throw new BadRequestHttpException('Duplicate relationships are not permitted. Use `meta.arity` to distinguish resource identifiers with matching `type` and `id` values.'
);
} return $resource_identifiers;
} /**
* Validates and massages the relationship input depending on the cardinality.
*
* @param array $data
* The input data from the body.
* @param bool $is_multiple
* Indicates if the relationship is to-many.
*
* @return array
* The massaged data array.
*/