Mercurial > hg > rr-repo
comparison sites/all/modules/bundle_inherit/bundle_inherit.install @ 4:ce11bbd8f642
added modules
author | danieleb <danielebarchiesi@me.com> |
---|---|
date | Thu, 19 Sep 2013 10:38:44 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
3:b28be78d8160 | 4:ce11bbd8f642 |
---|---|
1 <?php | |
2 /** | |
3 * @file | |
4 * Bundle Inherit module install file. | |
5 */ | |
6 | |
7 /** | |
8 * Implements hook_schema(). | |
9 */ | |
10 function bundle_inherit_schema() { | |
11 $schema['bundle_hierarchy'] = array( | |
12 'description' => 'Holds info about hierarchy relations between entity types.', | |
13 'fields' => array( | |
14 'entity_type' => array( | |
15 'description' => 'The entity type of the bundles.', | |
16 'type' => 'varchar', | |
17 'length' => '255', | |
18 'not null' => TRUE, | |
19 ), | |
20 'bundle' => array( | |
21 'description' => 'Child bundle name.', | |
22 'type' => 'varchar', | |
23 'length' => '255', | |
24 'not null' => TRUE, | |
25 ), | |
26 'bundle_parent' => array( | |
27 'description' => 'Parent bundle name.', | |
28 'type' => 'varchar', | |
29 'length' => '255', | |
30 'not null' => TRUE, | |
31 ), | |
32 ), | |
33 'primary key' => array('entity_type', 'bundle'), | |
34 'indexes' => array( | |
35 'parent' => array('entity_type', 'bundle_parent'), | |
36 ), | |
37 ); | |
38 | |
39 | |
40 return $schema; | |
41 } | |
42 | |
43 | |
44 /** | |
45 * Implements hook_uninstall(). | |
46 * | |
47 * We should remove 'locked' state from all inherited fields instances. | |
48 * | |
49 * @todo | |
50 * Maybe some better way to implement this function exists (talking about | |
51 * performance). But anyway we are getting info about instances from cache | |
52 * so I think that this implementation is more stable and logicaly loocking. | |
53 */ | |
54 function bundle_inherit_uninstall() { | |
55 $records = db_select('bundle_hierarchy', 'bh') | |
56 ->fields('bh') | |
57 ->execute(); | |
58 foreach ($records as $record) { | |
59 $instances = field_info_instances($record->entity_type, $record->bundle_parent); | |
60 foreach ($instances as $instance) { | |
61 $inherited_instance = field_info_instance($record->entity_type, $instance['field_name'], $record->bundle); | |
62 $inherited_instance['locked'] = FALSE; | |
63 field_update_instance($inherited_instance); | |
64 } | |
65 } | |
66 } |