You are here

function globallink_entity_save_field_collections in GlobalLink Connect for Drupal 7.5

Same name and namespace in other branches
  1. 7.7 globallink_entity/globallink_entity.inc \globallink_entity_save_field_collections()
  2. 7.6 globallink_entity/globallink_entity.inc \globallink_entity_save_field_collections()

Saves entity field collections.

Parameters

object $node: The entity node.

array $t_arr: The translated array.

string $target_lang: The node's target language.

File

globallink_entity/globallink_entity.inc, line 1181

Code

function globallink_entity_save_field_collections($node, $t_arr, $target_lang) {
  $field_arr = field_info_instances('node', $node->type);
  $keys = array_keys($field_arr);
  foreach ($keys as $field) {
    $items = field_get_items('node', $node, $field);
    if ($items) {
      $field_def = field_read_field($field);
      if ($field_def['type'] == 'field_collection') {
        if (isset($t_arr['field_collection'][$field])) {
          foreach ($items as $entity_id_arr) {
            if (isset($entity_id_arr['value'])) {
              $fc_entity_id = $entity_id_arr['value'];
              globallink_entity_save_field_collections_recursively('node', $node, $fc_entity_id, $t_arr['field_collection'][$field], $target_lang);
            }
          }
        }
      }
    }
  }
}