function ContentModerationHooks::entityBundleDelete

Implements hook_entity_bundle_delete().

File

core/modules/content_moderation/src/Hook/ContentModerationHooks.php, line 315

Class

ContentModerationHooks
Hook implementations for content_moderation.

Namespace

Drupal\content_moderation\Hook

Code

public function entityBundleDelete($entity_type_id, $bundle_id) {
    // Remove non-configuration based bundles from content moderation based
    // workflows when they are removed.
    foreach (Workflow::loadMultipleByType('content_moderation') as $workflow) {
        if ($workflow->getTypePlugin()
            ->appliesToEntityTypeAndBundle($entity_type_id, $bundle_id)) {
            $workflow->getTypePlugin()
                ->removeEntityTypeAndBundle($entity_type_id, $bundle_id);
            $workflow->save();
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.