function entity_test_bundle_class_entity_type_build

Implements hook_entity_type_build().

File

core/modules/system/tests/modules/entity_test_bundle_class/entity_test_bundle_class.module, line 67

Code

function entity_test_bundle_class_entity_type_build(array &$entity_types) : void {
    // Have multiple entity types share the same class as Entity Test.
    // This allows us to test that AmbiguousBundleClassException does not
    // get thrown when sharing classes.
    
    /** @var \Drupal\Core\Entity\ContentEntityType $original_type */
    $cloned_type = clone $entity_types['entity_test'];
    $cloned_type->set('bundle_of', 'entity_test');
    $entity_types['shared_type'] = $cloned_type;
    $entity_types['shared_type']->setClass(EntityTest::class);
}

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