summaryrefslogtreecommitdiffstats
path: root/har.install
blob: ded846d6a677cc429632d5d5addeb360df3088e4 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
/**
 * @file
 * Install and update functions for HAR module.
 */

/**
 * Implements hook_requirements().
 */
function har_requirements($phase) {
  if ($phase == 'runtime') {
    if (!is_dir(DRUPAL_ROOT . '/sites/all/libraries/har-view')) {
      $requirements['har-view']['description'] = t('Ensure https://github.com/s3u/har-view is in your sites/all/libraries directory.');
      $requirements['har-view']['severity'] = REQUIREMENT_WARNING;
      return $requirements;
    }
  }
}  

/**
 * Implements hook_install().
 */
function har_install() {
  // Clear the entity info cache so our new bundle gets picked up.
  drupal_static_reset('entity_get_info');
  cache_clear_all('entity_info', 'cache');
  field_attach_create_bundle('performance_data', 'har');
}

/**
 * Implements hook_uninstall().
 */
function har_uninstall() {
  field_attach_delete_bundle('performance_data', 'har');
}

/**
 * Define default fields.
 */
function har_default_fields() {
  $fields = array(
    'har_raw' => array(
      'field_name' => 'har_raw',
      'type' => 'text_long',
    ),
  );
  return $fields;
}

/**
 * Define instances for the HAR bundle.
 */
function har_default_instances() {
  $instances = array(
    'har_raw' => array(
      'field_name' => 'har_raw',
      'entity_type' => 'performance_data',
      'bundle' => 'har',
      'label' => 'HAR',
      'display' => array(
        'default' => array( 
          'type' => 'har_view',
        ),
      ),
    ),
  );
  return $instances;
}