You are here

function entity_test_delete_bundle in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/tests/modules/entity_test/entity_test.module \entity_test_delete_bundle()

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'.

3 calls to entity_test_delete_bundle()
EntityBundleFieldTest::testCustomBundleFieldUsage in core/modules/system/src/Tests/Entity/EntityBundleFieldTest.php
Tests making use of a custom bundle field.
EntityReferenceSettingsTest::testCustomTargetBundleDeletion in core/modules/field/src/Tests/EntityReference/EntityReferenceSettingsTest.php
Tests that deletions of custom bundles are mirrored in field settings.
FieldAttachStorageTest::testEntityDeleteBundle in core/modules/field/src/Tests/FieldAttachStorageTest.php
Test entity_bundle_delete().

File

core/modules/system/tests/modules/entity_test/entity_test.module, line 182
Test module for the entity API providing several entity types for testing.

Code

function entity_test_delete_bundle($bundle, $entity_type = 'entity_test') {
  $bundles = \Drupal::state()
    ->get($entity_type . '.bundles') ?: array(
    $entity_type => array(
      'label' => 'Entity Test Bundle',
    ),
  );
  unset($bundles[$bundle]);
  \Drupal::state()
    ->set($entity_type . '.bundles', $bundles);
  \Drupal::entityManager()
    ->onBundleDelete($bundle, $entity_type);
}