public function getRelated(ResourceType
$resource_type, FieldableEntityInterface
$entity,
$related, Request
$request) { /** @var \Drupal\Core\Field\EntityReferenceFieldItemListInterface $field_list */
$resource_relationship =
$resource_type->
getFieldByPublicName($related);
$field_list =
$entity->
get($resource_relationship->
getInternalName());
// Remove the entities pointing to a resource that may be disabled. Even
// though the normalizer skips disabled references, we can avoid unnecessary
// work by checking here too.
/** @var \Drupal\Core\Entity\EntityInterface[] $referenced_entities */
$referenced_entities =
array_filter( $field_list->
referencedEntities(),
function DEntityInterface
$entity) { return (bool) $this->resourceTypeRepository->
get( $entity->
getEntityTypeId(),