function FieldResolver::getAllDataReferencePropertyNames
Same name in other branches
- 9 core/modules/jsonapi/src/Context/FieldResolver.php \Drupal\jsonapi\Context\FieldResolver::getAllDataReferencePropertyNames()
- 8.9.x core/modules/jsonapi/src/Context/FieldResolver.php \Drupal\jsonapi\Context\FieldResolver::getAllDataReferencePropertyNames()
- 11.x core/modules/jsonapi/src/Context/FieldResolver.php \Drupal\jsonapi\Context\FieldResolver::getAllDataReferencePropertyNames()
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 core/
modules/ jsonapi/ src/ Context/ FieldResolver.php - Determines the reference property name for the remaining unresolved parts.
- 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 615
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);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.