function _farm_livestock_update_7005_stage5 in farmOS 7
Update 7005 stage 5: Clean up.
See also
1 call to _farm_livestock_update_7005_stage5()
- farm_livestock_update_7005 in modules/
farm/ farm_livestock/ farm_livestock.install - Create group assets for each animal group term, assign animals to new group assets, convert egg logs to harvest logs, and remove old animal groups taxonomy and related features.
File
- modules/
farm/ farm_livestock/ farm_livestock.install, line 447 - Farm livestock install file.
Code
function _farm_livestock_update_7005_stage5(&$sandbox) {
// If we are not on stage 5, bail.
if (empty($sandbox['stage']) || $sandbox['stage'] != 5) {
return;
}
// Delete the "Animal Groups" field instance from animal assets.
$field = field_info_instance('farm_asset', 'field_farm_animal_group', 'animal');
if (!empty($field)) {
field_delete_instance($field);
}
// Delete "Farm Animal Groups" View (if it still exists).
$view = views_get_view('farm_animal_groups');
if (!empty($view)) {
views_delete_view($view);
}
// Remove "Farm Animal Groups" taxonomy.
$group_vocab = taxonomy_vocabulary_machine_name_load('farm_animal_groups');
if (!empty($group_vocab)) {
taxonomy_vocabulary_delete($group_vocab->vid);
}
// Delete the egg logs View.
$view = views_get_view('farm_log_eggs');
if (!empty($view)) {
views_delete_view($view);
}
// Delete the egg log type.
$egg_log_type = log_type_load('farm_eggs');
if (!empty($egg_log_type)) {
log_type_delete($egg_log_type);
}
// Ensure that all field instances on egg logs are marked for deletion.
db_query("UPDATE {field_config_instance} SET deleted = 1 WHERE entity_type = 'log' AND bundle = 'farm_eggs'");
// We are finished!
$sandbox['#finished'] = 1;
}