You are here

public function ContentModeration::removeEntityTypeAndBundle in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/content_moderation/src/Plugin/WorkflowType/ContentModeration.php \Drupal\content_moderation\Plugin\WorkflowType\ContentModeration::removeEntityTypeAndBundle()
  2. 10 core/modules/content_moderation/src/Plugin/WorkflowType/ContentModeration.php \Drupal\content_moderation\Plugin\WorkflowType\ContentModeration::removeEntityTypeAndBundle()

Removes an entity type ID / bundle ID from the workflow.

Parameters

string $entity_type_id: The entity type ID to remove.

string $bundle_id: The bundle ID to remove.

Overrides ContentModerationInterface::removeEntityTypeAndBundle

1 call to ContentModeration::removeEntityTypeAndBundle()
ContentModeration::onDependencyRemoval in core/modules/content_moderation/src/Plugin/WorkflowType/ContentModeration.php
Informs the plugin that a dependency of the workflow will be deleted.

File

core/modules/content_moderation/src/Plugin/WorkflowType/ContentModeration.php, line 161

Class

ContentModeration
Attaches workflows to content entity types and their bundles.

Namespace

Drupal\content_moderation\Plugin\WorkflowType

Code

public function removeEntityTypeAndBundle($entity_type_id, $bundle_id) {
  if (!isset($this->configuration['entity_types'][$entity_type_id])) {
    return;
  }
  $key = array_search($bundle_id, $this->configuration['entity_types'][$entity_type_id], TRUE);
  if ($key !== FALSE) {
    unset($this->configuration['entity_types'][$entity_type_id][$key]);
    if (empty($this->configuration['entity_types'][$entity_type_id])) {
      unset($this->configuration['entity_types'][$entity_type_id]);
    }
    else {
      $this->configuration['entity_types'][$entity_type_id] = array_values($this->configuration['entity_types'][$entity_type_id]);
    }
  }
}