You are here

protected function FieldResolver::resourceTypesAreTraversable in JSON:API 8.2

Same name and namespace in other branches
  1. 8 src/Context/FieldResolver.php \Drupal\jsonapi\Context\FieldResolver::resourceTypesAreTraversable()

Whether the given resources can be traversed to other resources.

@todo This class shouldn't be aware of entity types and their definitions. Whether a resource can have relationships to other resources is information we ought to be able to discover on the ResourceType. However, we cannot reliably determine this information with existing APIs. Entities may be backed by various storages that are unable to perform queries across references and certain storages may not be able to store references at all.

Parameters

\Drupal\jsonapi\ResourceType\ResourceType[] $resource_types: The resources types to evaluate.

Return value

bool TRUE if any one of the given resource types is traversable.

1 call to FieldResolver::resourceTypesAreTraversable()
FieldResolver::resolveInternalEntityQueryPath in src/Context/FieldResolver.php
Resolves external field expressions into entity query compatible paths.

File

src/Context/FieldResolver.php, line 605

Class

FieldResolver
A service that evaluates external path expressions against Drupal fields.

Namespace

Drupal\jsonapi\Context

Code

protected function resourceTypesAreTraversable(array $resource_types) {
  foreach ($resource_types as $resource_type) {
    $entity_type_definition = $this->entityTypeManager
      ->getDefinition($resource_type
      ->getEntityTypeId());
    if ($entity_type_definition
      ->entityClassImplements(FieldableEntityInterface::class)) {
      return TRUE;
    }
  }
  return FALSE;
}