function globallink_delete_fc_items in GlobalLink Connect for Drupal 7.7
Same name and namespace in other branches
- 7.5 globallink.module \globallink_delete_fc_items()
- 7.6 globallink.module \globallink_delete_fc_items()
Removes an existing child field of field-collection from field config.
Parameters
string $content_type: The node content type.
string $parent_field_name: The field-collection parent name.
string $field_name: The field name.
string $entity_type: The field entity type.
3 calls to globallink_delete_fc_items()
- globallink_delete_fc in ./
globallink.module - Removes an existing field-collection field from field config.
- globallink_form_entity_translation_translatable_form_submit in ./
globallink.module - Submit function to synch up the content type field config changes with the globallink field config changes.
- globallink_form_field_ui_field_edit_form_submit in ./
globallink.module - Update field config for modified bundle field.
File
- ./
globallink.module, line 244 - GlobalLink translation module.
Code
function globallink_delete_fc_items($content_type, $parent_field_name, $field_name, $entity_type) {
$fc_field_info = field_info_field($field_name);
switch ($fc_field_info['type']) {
case 'list_boolean':
case 'image':
case 'file':
case 'taxonomy_term_reference':
break;
case 'field_collection':
// First delete the field-collection field.
db_delete('globallink_field_config')
->condition('content_type', $content_type, ' = ')
->condition('entity_type', $entity_type, ' = ')
->condition('bundle', $parent_field_name, ' = ')
->condition('field_name', $field_name, ' = ')
->execute();
$fc_field_infos = field_info_instances('field_collection_item');
if (isset($fc_field_infos) && isset($fc_field_infos[$field_name]) && is_array($fc_field_infos[$field_name])) {
$fc_items = array_keys($fc_field_infos[$field_name]);
foreach ($fc_items as $fc_item) {
// Delete all child fields recursively.
globallink_delete_fc_items($content_type, $field_name, $fc_item, $entity_type);
}
}
break;
default:
// Regular field-collection field, just delete from config.
db_delete('globallink_field_config')
->condition('content_type', $content_type, ' = ')
->condition('entity_type', $entity_type, ' = ')
->condition('bundle', $parent_field_name, ' = ')
->condition('field_name', $field_name, ' = ')
->execute();
}
}