$includes =
is_null($includes) ?
new IncludedData([]) :
$includes;
foreach ($include_tree as $field_name =>
$children) { $references =
[];
foreach ($data as $resource_object) { // Some objects in the collection may be LabelOnlyResourceObjects or
// EntityAccessDeniedHttpException objects.
assert($resource_object instanceof ResourceIdentifierInterface
);
$public_field_name =
$resource_object->
getResourceType()->
getPublicName($field_name);
if ($resource_object instanceof LabelOnlyResourceObject
) { $message = "The current user is not allowed to view this relationship.";
$exception =
new EntityAccessDeniedHttpException($resource_object->
getEntity(), AccessResult::
forbidden("The user only has authorization for the 'view label' operation."
), '',
$message,
$public_field_name);
$includes = IncludedData::
merge($includes,
new IncludedData([$exception]));
continue;
} elseif (!
$resource_object instanceof ResourceObject
) { continue;
} // Not all entities in $entity_collection will be of the same bundle and
// may not have all of the same fields. Therefore, calling
// $resource_object->get($a_missing_field_name) will result in an
// exception.