You are here

function globallink_delete_fc in GlobalLink Connect for Drupal 7.6

Same name and namespace in other branches
  1. 7.7 globallink.module \globallink_delete_fc()
  2. 7.5 globallink.module \globallink_delete_fc()

Removes an existing field-collection field from field config.

Parameters

string $content_type: The node content type.

string $fc_name: The field-collection field name.

string $entity_type: The field entity type.

string $bundle: The field bundle name.

3 calls to globallink_delete_fc()
globallink_form_entity_translation_translatable_form_submit in ./globallink.module
globallink_form_field_ui_field_delete_form_submit in ./globallink.module
Submit handler for delete link on Manage Fields Page of Content Type and Field Collection. This deletes a field from fields config table.
globallink_form_field_ui_field_edit_form_submit in ./globallink.module
Update field config for modified bundle field.

File

./globallink.module, line 177
GlobalLink translation module.

Code

function globallink_delete_fc($content_type, $fc_name, $entity_type, $bundle) {
  db_delete('globallink_field_config')
    ->condition('content_type', $content_type, ' = ')
    ->condition('entity_type', $entity_type, ' = ')
    ->condition('bundle', $bundle, ' = ')
    ->condition('field_name', $fc_name, ' = ')
    ->execute();
  $fc_field_infos = field_info_instances('field_collection_item');
  if (isset($fc_field_infos) && isset($fc_field_infos[$fc_name]) && is_array($fc_field_infos[$fc_name])) {
    $fc_items = array_keys($fc_field_infos[$fc_name]);
    foreach ($fc_items as $fc_item) {

      // All field collection items have entity type as field_collection_item
      globallink_delete_fc_items($content_type, $fc_name, $fc_item, 'field_collection_item');
    }
  }
}