protected function FieldResolver::getFieldItemDefinitions in Drupal 8
Same name and namespace in other branches
- 9 core/modules/jsonapi/src/Context/FieldResolver.php \Drupal\jsonapi\Context\FieldResolver::getFieldItemDefinitions()
Get all item definitions from a set of resources types by a field name.
Parameters
\Drupal\jsonapi\ResourceType\ResourceType[] $resource_types: The resource types on which the field might exist.
string $field_name: The field for which to retrieve field item definitions.
Return value
\Drupal\Core\TypedData\ComplexDataDefinitionInterface[] The found field item definitions.
1 call to FieldResolver::getFieldItemDefinitions()
- 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 485
Class
- FieldResolver
- A service that evaluates external path expressions against Drupal fields.
Namespace
Drupal\jsonapi\ContextCode
protected function getFieldItemDefinitions(array $resource_types, $field_name) {
return array_reduce($resource_types, function ($result, ResourceType $resource_type) use ($field_name) {
/* @var \Drupal\jsonapi\ResourceType\ResourceType $resource_type */
$entity_type = $resource_type
->getEntityTypeId();
$bundle = $resource_type
->getBundle();
$definitions = $this->fieldManager
->getFieldDefinitions($entity_type, $bundle);
if (isset($definitions[$field_name])) {
$result[$resource_type
->getTypeName()] = $definitions[$field_name]
->getItemDefinition();
}
return $result;
}, []);
}