public function EntityHierarchy::onDependencyRemoval in Entity Reference Hierarchy 8.2
Same name and namespace in other branches
- 3.x modules/entity_hierarchy_workbench_access/src/Plugin/AccessControlHierarchy/EntityHierarchy.php \Drupal\entity_hierarchy_workbench_access\Plugin\AccessControlHierarchy\EntityHierarchy::onDependencyRemoval()
Informs the plugin that a dependency of the scheme will be deleted.
@todo https://www.drupal.org/node/2579743 make part of a generic interface.
Parameters
array $dependencies: An array of dependencies that will be deleted keyed by dependency type.
Return value
bool TRUE if the workflow settings have been changed, FALSE if not.
Overrides AccessControlHierarchyBase::onDependencyRemoval
See also
\Drupal\Core\Config\ConfigEntityInterface::onDependencyRemoval()
File
- modules/
entity_hierarchy_workbench_access/ src/ Plugin/ AccessControlHierarchy/ EntityHierarchy.php, line 362
Class
- EntityHierarchy
- Defines a hierarchy based on an entity hierarchy field.
Namespace
Drupal\entity_hierarchy_workbench_access\Plugin\AccessControlHierarchyCode
public function onDependencyRemoval(array $dependencies) {
$fields = array_diff($this->configuration['boolean_fields'], array_reduce($dependencies['config'], function (array $carry, $item) {
if (!$item instanceof FieldConfigInterface) {
return $carry;
}
if ($item
->getTargetEntityTypeId() !== $this->pluginDefinition['entity']) {
return $carry;
}
$carry[] = $item
->getName();
return $carry;
}, []));
$entityType = $this->entityTypeManager
->getDefinition($this->pluginDefinition['entity']);
$bundles = [];
if ($bundle = $entityType
->getBundleEntityType()) {
$bundleType = $this->entityTypeManager
->getDefinition($bundle);
$bundles = array_diff($this->configuration['bundles'], array_reduce($dependencies['config'], function (array $carry, $item) use ($bundleType) {
if (in_array($bundleType
->getClass(), class_parents($item))) {
return $carry;
}
$carry[] = $item
->id();
return $carry;
}, []));
}
$changed = $fields != $this->configuration['boolean_fields'] || $bundles != $this->configuration['bundles'];
$this->configuration['boolean_fields'] = $fields;
$this->configuration['bundles'] = $bundles;
return $changed;
}