You are here

function biblio_delete_fields in Bibliography Module 7.2

Deletes all Biblio fields

Return value

array Array of all fields that were deleted.

1 call to biblio_delete_fields()
biblio_uninstall in ./biblio.install

File

includes/biblio.fields.inc, line 209

Code

function biblio_delete_fields() {
  $db_fields = array(
    'id',
    'field_name',
    'entity_type',
    'bundle',
  );
  $result = db_select('field_config_instance', 'fci')
    ->fields('fci', $db_fields)
    ->condition(db_or()
    ->condition('entity_type', 'biblio')
    ->condition('entity_type', 'biblio_contributor'))
    ->condition('deleted', '0')
    ->execute();

  // while ($row = $result->fetchAssoc()) {
  //   $instances_to_delete[] = $row;
  // }
  // $batch = array(
  //   'title' => t('Deleting Field Instances'),
  //   'operations' => array(
  //     array('biblio_batch_delete_field', array($instances_to_delete)),
  //   ),
  //   'finished' => 'biblio_batch_delete_field_finished',
  // );
  // batch_set($batch);
  // batch_process('admin/modules');
  while ($row = $result
    ->fetchAssoc()) {
    field_delete_instance($row, TRUE);
  }
  $fields = biblio_field_list();
  foreach ($fields as $field) {

    // Each iteration takes ~90ms to run
    field_delete_field($field);
  }
  return $fields;
}