function FieldResolver::getRelatableResourceTypes
Same name in other branches
- 9 core/modules/jsonapi/src/Context/FieldResolver.php \Drupal\jsonapi\Context\FieldResolver::getRelatableResourceTypes()
- 8.9.x core/modules/jsonapi/src/Context/FieldResolver.php \Drupal\jsonapi\Context\FieldResolver::getRelatableResourceTypes()
- 10 core/modules/jsonapi/src/Context/FieldResolver.php \Drupal\jsonapi\Context\FieldResolver::getRelatableResourceTypes()
Get the referenceable ResourceTypes for a set of field definitions.
Parameters
\Drupal\jsonapi\ResourceType\ResourceType[] $resource_types: The resource types on which the reference field might exist.
\Drupal\Core\Field\TypedData\FieldItemDataDefinitionInterface[] $definitions: The field item definitions of targeted fields, keyed by the resource type name on which they reside.
Return value
\Drupal\jsonapi\ResourceType\ResourceType[] The referenceable target resource types.
1 call to FieldResolver::getRelatableResourceTypes()
- FieldResolver::resolveInternalEntityQueryPath in core/
modules/ jsonapi/ src/ Context/ FieldResolver.php - Resolves external field expressions into entity query compatible paths.
File
-
core/
modules/ jsonapi/ src/ Context/ FieldResolver.php, line 566
Class
- FieldResolver
- A service that evaluates external path expressions against Drupal fields.
Namespace
Drupal\jsonapi\ContextCode
protected function getRelatableResourceTypes(array $resource_types, array $definitions) {
$relatable_resource_types = [];
foreach ($resource_types as $resource_type) {
$definition = $definitions[$resource_type->getTypeName()];
$resource_type_field = $resource_type->getFieldByInternalName($definition->getFieldDefinition()
->getName());
if ($resource_type_field instanceof ResourceTypeRelationship) {
foreach ($resource_type_field->getRelatableResourceTypes() as $relatable_resource_type) {
$relatable_resource_types[$relatable_resource_type->getTypeName()] = $relatable_resource_type;
}
}
}
return $relatable_resource_types;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.