Project

General

Profile

Paste
Download (2.44 KB) Statistics
| Branch: | Revision:

root / drupal7 / sites / all / modules / ctools / tests / ctools_export_test / ctools_export_test.install @ 6e3ce7c2

1
<?php
2

    
3
/**
4
 * @file
5
 */
6

    
7
/**
8
 * Implements hook_schema().
9
 */
10
function ctools_export_test_schema() {
11
  $schema['ctools_export_test'] = array(
12
    'description' => 'CTools export test data table',
13
    'export' => array(
14
      'key' => 'machine',
15
      'identifier' => 'ctools_export_test',
16
      'default hook' => 'default_ctools_export_tests',
17
      'bulk export' => TRUE,
18
      'api' => array(
19
        'owner' => 'ctools_export_test',
20
        'api' => 'default_ctools_export_tests',
21
        'minimum_version' => 1,
22
        'current_version' => 1,
23
      ),
24
    ),
25
    'fields' => array(
26
      'machine' => array(
27
        'description' => "The unique machine name (required by ctools).",
28
        'type' => 'varchar',
29
        'length' => 255,
30
        'not null' => TRUE,
31
        'default' => '',
32
      ),
33
      'title' => array(
34
        'description' => "The human readable title.",
35
        'type' => 'varchar',
36
        'length' => 255,
37
        'not null' => TRUE,
38
        'default' => '',
39
      ),
40
      'number' => array(
41
        'description' => "A number.",
42
        'type' => 'int',
43
        'not null' => TRUE,
44
        'default' => 0,
45
      ),
46
      'data' => array(
47
        'type' => 'blob',
48
        'description' => "A serialized array of data.",
49
        'serialize' => TRUE,
50
        'serialized default' => 'a:0:{}',
51
      ),
52
    ),
53
    'primary key' => array('machine'),
54
  );
55

    
56
  return $schema;
57
}
58

    
59
/**
60
 * Implements hook_install().
61
 */
62
function ctools_export_test_install() {
63
  $ctools_export_tests = array();
64
  // Put this default in the database only (no default).
65
  $ctools_export_test = new stdClass();
66
  $ctools_export_test->machine = 'database_test';
67
  $ctools_export_test->title = 'Database test';
68
  $ctools_export_test->number = 0;
69
  $ctools_export_test->data = array(
70
    'test_1' => 'Test 1',
71
    'test_2' => 'Test 2',
72
  );
73
  $ctools_export_tests['database_test'] = $ctools_export_test;
74

    
75
  // Put this default in the database, so we have this in code and in the database.
76
  $ctools_export_test = new stdClass();
77
  $ctools_export_test->machine = 'overridden_test';
78
  $ctools_export_test->title = 'Overridden test';
79
  $ctools_export_test->number = 1;
80
  $ctools_export_test->data = array(
81
    'test_1' => 'Test 1',
82
    'test_2' => 'Test 2',
83
  );
84
  $ctools_export_tests['overridden_test'] = $ctools_export_test;
85

    
86
  foreach ($ctools_export_tests as $ctools_export_test) {
87
    // Save the record to the database.
88
    drupal_write_record('ctools_export_test', $ctools_export_test);
89
  }
90
}