Call field_attach_create_bundle() from hook_install().
[project/har.git] / har.install
1 <?php
2 /**
3 * @file
4 * Install and update functions for HAR module.
5 */
6
7 /**
8 * Implements hook_requirements().
9 */
10 function har_requirements($phase) {
11 if ($phase == 'runtime') {
12 if (!is_dir(DRUPAL_ROOT . '/sites/all/libraries/har-view')) {
13 $requirements['har-view']['description'] = t('Ensure https://github.com/s3u/har-view is in your sites/all/libraries directory.');
14 $requirements['har-view']['severity'] = REQUIREMENT_WARNING;
15 return $requirements;
16 }
17 }
18 }
19
20 /**
21 * Implements hook_install().
22 */
23 function har_install() {
24 // Clear the entity info cache so our new bundle gets picked up.
25 drupal_static_reset('entity_get_info');
26 cache_clear_all('entity_info', 'cache');
27 field_attach_create_bundle('performance_data', 'har');
28 }
29
30 /**
31 * Implements hook_uninstall().
32 */
33 function har_uninstall() {
34 field_attach_delete_bundle('performance_data', 'har');
35 }
36
37 /**
38 * Define default fields.
39 */
40 function har_default_fields() {
41 $fields = array(
42 'har_raw' => array(
43 'field_name' => 'har_raw',
44 'type' => 'text_long',
45 ),
46 );
47 return $fields;
48 }
49
50 /**
51 * Define instances for the HAR bundle.
52 */
53 function har_default_instances() {
54 $instances = array(
55 'har_raw' => array(
56 'field_name' => 'har_raw',
57 'entity_type' => 'performance_data',
58 'bundle' => 'har',
59 'label' => 'HAR',
60 'display' => array(
61 'default' => array(
62 'type' => 'har_view',
63 ),
64 ),
65 ),
66 );
67 return $instances;
68 }