function commerce_donate_install in Commerce Donate 7
Implements hook_install().
File
- ./
commerce_donate.install, line 12 - Installation file for commerce_donate. Creates necessary entity fields on installation.
Code
function commerce_donate_install() {
module_load_include('inc', 'commerce_donate', 'includes/commerce_donate.field');
if ($fields = commerce_donate_get_fields()) {
field_info_cache_clear();
foreach ($fields as $field) {
// Create or update field.
$field_config = $field['field_config'];
$existing_field = field_info_field($field_config['field_name']);
if (empty($existing_field)) {
field_create_field($field_config);
}
// Create or update field instance.
$field_instance = $field['field_instance'];
$existing_instance = field_info_instance($field_instance['entity_type'], $field_instance['field_name'], $field_instance['bundle']);
if ($existing_instance) {
field_update_instance($field_instance);
}
else {
field_create_instance($field_instance);
}
variable_set('menu_rebuild_needed', TRUE);
}
}
}