You are here

protected function FieldResolver::getReferenceableResourceTypes in JSON:API 8.2

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

Get the referenceable ResourceTypes for a set of field definitions.

Parameters

\Drupal\Core\Field\FieldDefinitionInterface[] $definitions: The resource types on which the reference field might exist.

Return value

\Drupal\jsonapi\ResourceType\ResourceType[] The referenceable target resource types.

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

File

src/Context/FieldResolver.php, line 545

Class

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

Namespace

Drupal\jsonapi\Context

Code

protected function getReferenceableResourceTypes(array $definitions) {
  return array_reduce($definitions, function ($result, $definition) {
    $resource_types = array_filter($this
      ->collectResourceTypesForReference($definition));
    $type_names = array_map(function ($resource_type) {

      /* @var \Drupal\jsonapi\ResourceType\ResourceType $resource_type */
      return $resource_type
        ->getTypeName();
    }, $resource_types);
    return array_merge($result, array_combine($type_names, $resource_types));
  }, []);
}