You are here

function globallink_entity_save_field_collections in GlobalLink Connect for Drupal 7.6

Same name and namespace in other branches
  1. 7.7 globallink_entity/globallink_entity.inc \globallink_entity_save_field_collections()
  2. 7.5 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.

1 call to globallink_entity_save_field_collections()
globallink_entity_save_translated_entity_with_fields in globallink_entity/globallink_entity.inc
Saves translated entity with fields.

File

globallink_entity/globallink_entity.inc, line 1214

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);
            }
          }
        }
      }
    }
  }
}