public function ContentModeration::onDependencyRemoval in Drupal 9
Same name and namespace in other branches
- 8 core/modules/content_moderation/src/Plugin/WorkflowType/ContentModeration.php \Drupal\content_moderation\Plugin\WorkflowType\ContentModeration::onDependencyRemoval()
Informs the plugin that a dependency of the workflow 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 WorkflowTypeBase::onDependencyRemoval
See also
\Drupal\Core\Config\ConfigEntityInterface::onDependencyRemoval()
File
- core/
modules/ content_moderation/ src/ Plugin/ WorkflowType/ ContentModeration.php, line 251
Class
- ContentModeration
- Attaches workflows to content entity types and their bundles.
Namespace
Drupal\content_moderation\Plugin\WorkflowTypeCode
public function onDependencyRemoval(array $dependencies) {
$changed = parent::onDependencyRemoval($dependencies);
// When bundle config entities are removed, ensure they are cleaned up from
// the workflow.
foreach ($dependencies['config'] as $removed_config) {
if ($entity_type_id = $removed_config
->getEntityType()
->getBundleOf()) {
$bundle_id = $removed_config
->id();
$this
->removeEntityTypeAndBundle($entity_type_id, $bundle_id);
$changed = TRUE;
}
}
// When modules that provide entity types are removed, ensure they are also
// removed from the workflow.
if (!empty($dependencies['module'])) {
// Gather all entity definitions provided by the dependent modules which
// are being removed.
$module_entity_definitions = [];
foreach ($this->entityTypeManager
->getDefinitions() as $entity_definition) {
if (in_array($entity_definition
->getProvider(), $dependencies['module'])) {
$module_entity_definitions[] = $entity_definition;
}
}
// For all entity types provided by the uninstalled modules, remove any
// configuration for those types.
foreach ($module_entity_definitions as $module_entity_definition) {
foreach ($this
->getBundlesForEntityType($module_entity_definition
->id()) as $bundle) {
$this
->removeEntityTypeAndBundle($module_entity_definition
->id(), $bundle);
$changed = TRUE;
}
}
}
return $changed;
}