function EntityTestHelper::deleteBundle
Deletes a bundle for entity_test entities.
Parameters
string $bundle: The machine-readable name of the bundle to delete.
string $entity_type: (optional) The entity type for which the bundle is deleted. Defaults to 'entity_test'.
See also
\Drupal\entity_test\Hook\EntityTestHooks::entityBundleInfo()
6 calls to EntityTestHelper::deleteBundle()
- ContentModerationStateTest::testWorkflowNonConfigBundleDependencies in core/
modules/ content_moderation/ tests/ src/ Kernel/ ContentModerationStateTest.php - Tests the content moderation workflow dependencies for non-config bundles.
- EntityAddUITest::testAddPageWithoutBundleEntities in core/
modules/ system/ tests/ src/ Functional/ Entity/ EntityAddUITest.php - Tests the add page for an entity type not using bundle entities.
- EntityBundleFieldTest::testCustomBundleFieldUsage in core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityBundleFieldTest.php - Tests making use of a custom bundle field.
- EntityReferenceSettingsTest::testCustomTargetBundleDeletion in core/
modules/ field/ tests/ src/ Kernel/ EntityReference/ EntityReferenceSettingsTest.php - Tests that deletions of custom bundles are mirrored in field settings.
- entity_test_delete_bundle in core/
modules/ system/ tests/ modules/ entity_test/ entity_test.module - Deletes a bundle for entity_test entities.
File
-
core/
modules/ system/ tests/ modules/ entity_test/ src/ EntityTestHelper.php, line 89
Class
- EntityTestHelper
- Class for the entity API providing several entity types for testing.
Namespace
Drupal\entity_testCode
public static function deleteBundle($bundle, $entity_type = 'entity_test') : void {
$bundles = \Drupal::state()->get($entity_type . '.bundles', [
$entity_type => [
'label' => 'Entity Test Bundle',
],
]);
unset($bundles[$bundle]);
\Drupal::state()->set($entity_type . '.bundles', $bundles);
\Drupal::service('entity_bundle.listener')->onBundleDelete($bundle, $entity_type);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.