protected function EntityTraversal::getAllReverseRelationships in General Data Protection Regulation 3.0.x
Same name and namespace in other branches
- 8.2 modules/gdpr_fields/src/EntityTraversal.php \Drupal\gdpr_fields\EntityTraversal::getAllReverseRelationships()
- 8 modules/gdpr_fields/src/EntityTraversal.php \Drupal\gdpr_fields\EntityTraversal::getAllReverseRelationships()
Gets all reverse relationships configured in the system.
Return value
array Information about reversible relationships.
1 call to EntityTraversal::getAllReverseRelationships()
- EntityTraversal::doTraversalRecursive in modules/
gdpr_fields/ src/ EntityTraversal.php - Traverses the entity relationship tree.
File
- modules/
gdpr_fields/ src/ EntityTraversal.php, line 257
Class
- EntityTraversal
- Base class for traversing entities.
Namespace
Drupal\gdpr_fieldsCode
protected function getAllReverseRelationships() {
if ($this->reverseRelationshipFields !== NULL) {
// Make sure reverse relationships are cached.
// as this is called many times in the recursion loop.
return $this->reverseRelationshipFields;
}
$this->reverseRelationshipFields = [];
/** @var \Drupal\gdpr_fields\Entity\GdprFieldConfigEntity $config */
foreach ($this->configStorage
->loadMultiple() as $config) {
foreach ($config
->getAllFields() as $field) {
if ($field->enabled && $field
->isOwner()) {
foreach ($this->entityFieldManager
->getFieldDefinitions($config
->id(), $field->bundle) as $fieldDefinition) {
if ($fieldDefinition
->getName() === $field->name && $fieldDefinition
->getType() === 'entity_reference') {
$this->reverseRelationshipFields[] = [
'entity_type' => $config
->id(),
'bundle' => $field->bundle,
'field' => $field->name,
'config' => $field,
'target_type' => $fieldDefinition
->getSetting('target_type'),
];
}
}
}
}
}
return $this->reverseRelationshipFields;
}