You are here

function globallink_insert_fc in GlobalLink Connect for Drupal 7.5

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

Adds field-collection field to field config.

Parameters

string $entity_type: The field entity type.

string $fc_name: The field-collection name.

string $content_type: The node content type.

string $bundle: The field bundle name.

2 calls to globallink_insert_fc()
globallink_form_field_ui_field_overview_form_submit in ./globallink.module
Submit handler for Manage Fields Page of Content Type and Field Collection. Adds a new field being added to the fields config table for translation.
globallink_insert_gl_field_config in ./globallink_field_configuration.inc
Inserts GlobalLink field configuration.

File

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

Code

function globallink_insert_fc($entity_type, $fc_name, $content_type, $bundle) {
  $fc_field_info = field_info_field($fc_name);
  $fc_field_instance = field_info_instance($entity_type, $fc_name, $bundle);

  // Add FC field to the config
  db_insert('globallink_field_config')
    ->fields(array(
    'content_type' => $content_type,
    'entity_type' => $entity_type,
    'bundle' => $bundle,
    'field_name' => $fc_name,
    'field_type' => $fc_field_info['type'],
    'field_label' => $fc_field_instance['label'],
    'translatable' => 0,
  ))
    ->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) {

      // Add all the FC field items recursively
      globallink_insert_fc_items($content_type, $fc_name, $fc_item);
    }
  }
}