$target_type =
$field_list->
getFieldDefinition()->
getFieldStorageDefinition()->
getSetting('target_type'
);
assert(!
empty($target_type));
foreach ($field_list as $field_item) { assert($field_item instanceof EntityReferenceItem
);
$references[$target_type][] =
$field_item->
get($field_item::
mainPropertyName())->
getValue();
} } foreach ($references as $target_type =>
$ids) { $entity_storage =
$this->entityTypeManager->
getStorage($target_type);
$targeted_entities =
$entity_storage->
loadMultiple(array_unique($ids));
$access_checked_entities =
array_map(function DEntityInterface
$entity) { return $this->entityAccessChecker->
getAccessCheckedResourceObject($entity);
},
$targeted_entities);
$targeted_collection =
new IncludedData(array_filter($access_checked_entities,
function DResourceIdentifierInterface
$resource_object) { return !
$resource_object->
getResourceType()->
isInternal();
}));
$includes =
static::
resolveIncludeTree($children,
$targeted_collection, IncludedData::
merge($includes,
$targeted_collection));
} } return $includes;
} /**
* Returns a tree of field names to include from an include parameter.
*
* @param \Drupal\jsonapi\JsonApiResource\ResourceObjectData $data
* The base resources for which includes should be resolved.
* @param string $include_parameter
* The raw include parameter value.
*
* @return array
* A multi-dimensional array representing a tree of field names to be
* included. Array keys are the field names. Leaves are empty arrays.
*/