protected static function ResourceIdentifier::getDataReferencePropertyName in JSON:API 8.2
Helper method to determine which field item property contains an entity.
Parameters
\Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem $item: The entity reference item for which to determine the entity property name.
Return value
string The property name which has an entity as its value.
2 calls to ResourceIdentifier::getDataReferencePropertyName()
- ResourceIdentifier::getVirtualOrMissingResourceIdentifier in src/
JsonApiResource/ ResourceIdentifier.php - Creates a ResourceIdentifier for a NULL or FALSE entity reference item.
- ResourceIdentifier::toResourceIdentifier in src/
JsonApiResource/ ResourceIdentifier.php - Creates a ResourceIdentifier object.
File
- src/
JsonApiResource/ ResourceIdentifier.php, line 391
Class
- ResourceIdentifier
- Represents a JSON:API resource identifier object.
Namespace
Drupal\jsonapi\JsonApiResourceCode
protected static function getDataReferencePropertyName(EntityReferenceItem $item) {
foreach ($item
->getDataDefinition()
->getPropertyDefinitions() as $property_name => $property_definition) {
if ($property_definition instanceof DataReferenceDefinitionInterface) {
return $property_name;
}
}
}