You are here

function pm_uninstall_fields in Drupal PM (Project Management) 8

Same name and namespace in other branches
  1. 7.3 includes/pm.install.inc \pm_uninstall_fields()

Deletes field instances and bases from a given list.

10 calls to pm_uninstall_fields()
pmexpense_uninstall in pmexpense/pmexpense.install
Implements hook_uninstall().
pmissue_uninstall in pmissue/pmissue.install
Implements hook_uninstall().
pmnote_uninstall in pmnote/pmnote.install
Implements hook_uninstall().
pmorganization_uninstall in pmorganization/pmorganization.install
Implements hook_uninstall().
pmperson_uninstall in pmperson/pmperson.install
Implements hook_uninstall().

... See full list

File

includes/pm.install.inc, line 60
Helper functions for install, disable, uninstall and update of PM modules.

Code

function pm_uninstall_fields($module) {

  // Determine which fields were declared by the specified module.
  module_load_include('inc', $module, 'includes/' . $module . '.field_base');
  module_load_include('inc', $module, 'includes/' . $module . '.field_instance');
  $field_bases = module_invoke($module, 'default_field_bases');
  $field_instances = module_invoke($module, 'default_field_instances');
  foreach ($field_instances as $instance) {

    // Only attempt to delete instances that still exist.
    $instance_info = field_info_instance($instance['entity_type'], $instance['field_name'], $instance['bundle']);
    if ($instance_info) {

      // Only delete field base if provided in the list of bases.
      $delete_field_base = isset($field_bases[$instance['field_name']]);
      field_delete_instance($instance, $delete_field_base);
    }
  }
}