5 * Install, update and uninstall functions for the entity_test module.
8 use Drupal\system\Tests\Update\DbUpdatesTrait;
9 use Drupal\field\Entity\FieldStorageConfig;
10 use Drupal\field\Entity\FieldConfig;
13 * Implements hook_install().
15 function entity_test_install() {
16 foreach (entity_test_entity_types() as $entity_type) {
17 // Auto-create fields for testing.
18 FieldStorageConfig::create([
19 'entity_type' => $entity_type,
20 'field_name' => 'field_test_text',
25 'entity_type' => $entity_type,
26 'field_name' => 'field_test_text',
27 'bundle' => $entity_type,
28 'label' => 'Test text-field',
29 'translatable' => FALSE,
32 entity_get_form_display($entity_type, $entity_type, 'default')
33 ->setComponent('field_test_text', ['type' => 'text_textfield'])
39 * Implements hook_schema().
41 function entity_test_schema() {
42 // Schema for simple entity.
43 $schema['entity_test_example'] = [
44 'description' => 'Stores entity_test items.',
49 'description' => 'Primary Key: Unique entity-test item ID.',
52 'primary key' => ['id'],
57 DbUpdatesTrait::includeUpdates('entity_test', 'entity_definition_updates');
58 DbUpdatesTrait::includeUpdates('entity_test', 'status_report');