public function EntityHierarchy::calculateDependencies in Entity Reference Hierarchy 3.x
Same name and namespace in other branches
- 8.2 modules/entity_hierarchy_workbench_access/src/Plugin/AccessControlHierarchy/EntityHierarchy.php \Drupal\entity_hierarchy_workbench_access\Plugin\AccessControlHierarchy\EntityHierarchy::calculateDependencies()
File
- modules/
entity_hierarchy_workbench_access/ src/ Plugin/ AccessControlHierarchy/ EntityHierarchy.php, line 275
Class
- EntityHierarchy
- Defines a hierarchy based on an entity hierarchy field.
Namespace
Drupal\entity_hierarchy_workbench_access\Plugin\AccessControlHierarchyCode
public function calculateDependencies() {
$dependent_entities = [];
$fieldStorage = $this->entityTypeManager
->getStorage('field_storage_config');
$dependent_entities[] = $fieldStorage
->load(sprintf('%s.%s', $this->pluginDefinition['entity'], $this->pluginDefinition['field_name']));
foreach ($this->configuration['boolean_fields'] as $field_name) {
if ($field = $fieldStorage
->load(sprintf('%s.%s', $this->pluginDefinition['entity'], $field_name))) {
$dependent_entities[] = $field;
}
}
$entityType = $this->entityTypeManager
->getDefinition($this->pluginDefinition['entity']);
if ($bundle = $entityType
->getBundleEntityType()) {
$dependent_entities = array_merge($dependent_entities, $this->entityTypeManager
->getStorage($bundle)
->loadMultiple($this->configuration['bundles']));
}
return array_reduce($dependent_entities, function (array $carry, EntityInterface $entity) {
$carry[$entity
->getConfigDependencyKey()][] = $entity
->getConfigDependencyName();
return $carry;
}, []);
}