protected static function FieldResolver::getAllDataReferencePropertyNames in JSON:API 8.2
Gets all unique reference property names from the given field definitions.
Parameters
\Drupal\Core\TypedData\ComplexDataDefinitionInterface[] $candidate_definitions: A list of targeted field item definitions specified by the path.
Return value
string[] The reference property names, if any.
2 calls to FieldResolver::getAllDataReferencePropertyNames()
- FieldResolver::getDataReferencePropertyName in src/
Context/ FieldResolver.php - Determines the reference property name for the remaining unresolved parts.
- FieldResolver::resolveInternalEntityQueryPath in src/
Context/ FieldResolver.php - Resolves external field expressions into entity query compatible paths.
File
- src/
Context/ FieldResolver.php, line 637
Class
- FieldResolver
- A service that evaluates external path expressions against Drupal fields.
Namespace
Drupal\jsonapi\ContextCode
protected static function getAllDataReferencePropertyNames(array $candidate_definitions) {
$reference_property_names = array_reduce($candidate_definitions, function (array $reference_property_names, ComplexDataDefinitionInterface $definition) {
$property_definitions = $definition
->getPropertyDefinitions();
foreach ($property_definitions as $property_name => $property_definition) {
if ($property_definition instanceof DataReferenceDefinitionInterface) {
$target_definition = $property_definition
->getTargetDefinition();
assert($target_definition instanceof EntityDataDefinitionInterface, 'Entity reference fields should only be able to reference entities.');
$reference_property_names[] = $property_name . ':' . $target_definition
->getEntityTypeId();
}
}
return $reference_property_names;
}, []);
return array_unique($reference_property_names);
}