summaryrefslogtreecommitdiffstats
path: root/core/modules/system/tests/modules/entity_test/entity_test.install
blob: 1a6d9a2171a2941bf6741e9f8055806263bd322d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php

/**
 * @file
 * Install, update and uninstall functions for the entity_test module.
 */

/**
 * Implements hook_install().
 */
function entity_test_install() {
  foreach (entity_test_entity_types() as $entity_type) {
    // Auto-create fields for testing.
    entity_create('field_storage_config', array(
      'entity_type' => $entity_type,
      'field_name' => 'field_test_text',
      'type' => 'text',
      'cardinality' => 1,
    ))->save();
    entity_create('field_config', array(
      'entity_type' => $entity_type,
      'field_name' => 'field_test_text',
      'bundle' => $entity_type,
      'label' => 'Test text-field',
      'translatable' => FALSE,
    ))->save();

    entity_get_form_display($entity_type, $entity_type, 'default')
      ->setComponent('field_test_text', array('type' => 'text_textfield'))
      ->save();
  }
}

/**
 * Implements hook_schema().
 */
function entity_test_schema() {
  // Schema for simple entity.
  $schema['entity_test_example'] = array(
    'description' => 'Stores entity_test items.',
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Primary Key: Unique entity-test item ID.',
      ),
    ),
    'primary key' => array('id'),
  );
  return $schema;
}