You are here

function entity_schema_test_entity_bundle_create in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/tests/modules/entity_schema_test/entity_schema_test.module \entity_schema_test_entity_bundle_create()
  2. 9 core/modules/system/tests/modules/entity_schema_test/entity_schema_test.module \entity_schema_test_entity_bundle_create()

Implements hook_entity_bundle_create().

File

core/modules/system/tests/modules/entity_schema_test/entity_schema_test.module, line 84
Test module for the entity API providing a bundle field.

Code

function entity_schema_test_entity_bundle_create($entity_type_id, $bundle) {
  if ($entity_type_id == 'entity_test_update' && $bundle == 'custom') {
    $field_definitions = \Drupal::service('entity_field.manager')
      ->getFieldDefinitions($entity_type_id, $bundle);

    // Notify the entity storage that we just created a new field.
    \Drupal::service('field_definition.listener')
      ->onFieldDefinitionCreate($field_definitions['custom_bundle_field']);
  }
}