public function DependencyFieldMapGenerator::getReferentialFieldMap in Entity Reference Integrity 8
A field map keyed by the entity type being targeted by reference fields.
The referential field map is in the format of:
entity_type_id_being_referenced: source_entity_type_id:
- referencing_field_a
- referencing_field_b
Return value
array A field map.
Overrides DependencyFieldMapGeneratorInterface::getReferentialFieldMap
1 call to DependencyFieldMapGenerator::getReferentialFieldMap()
- DependencyFieldMapGenerator::getReferencingFields in src/
DependencyFieldMapGenerator.php - Get the segment of the field map for a specific entity type ID.
File
- src/
DependencyFieldMapGenerator.php, line 55
Class
- DependencyFieldMapGenerator
- Create a map of reference fields.
Namespace
Drupal\entity_reference_integrityCode
public function getReferentialFieldMap() {
$referential_field_map = [];
foreach ($this->entityFieldManager
->getFieldMapByFieldType($this->fieldType) as $source_entity_type_id => $fields) {
$source_entity_storage_definitions = $this->entityFieldManager
->getFieldStorageDefinitions($source_entity_type_id);
$source_entity_type = $this->entityTypeManager
->getDefinition($source_entity_type_id);
foreach ($fields as $field_name => $field_data) {
$field_storage_definition = !empty($source_entity_storage_definitions[$field_name]) ? $source_entity_storage_definitions[$field_name] : FALSE;
// Some fields like computed fields do not show up in the return value
// of getFieldStorageDefinitions.
if (!$field_storage_definition) {
continue;
}
// Fields with custom storage like term parents can't be used with
// entity query.
if ($field_storage_definition
->hasCustomStorage()) {
continue;
}
// Don't query against revision metadata fields.
if (in_array($field_name, $source_entity_type
->getRevisionMetadataKeys())) {
continue;
}
$target_entity_type_id = $source_entity_storage_definitions[$field_name]
->getSetting($this->targetEntitySettingsKey);
$referential_field_map[$target_entity_type_id][$source_entity_type_id][] = $field_name;
}
}
return $referential_field_map;
}