You are here

function location_feeds_set_target in Location Feeds 6

Same name and namespace in other branches
  1. 7 location_feeds.module \location_feeds_set_target()

Implementation of feed_set_target

Parameters

object $object: Either a user or node object dpending on where this is called

string $target: When targeting sub arrays the '][' is used to drill down. Note that this implementation is lazy ... we assume just depth=2

$value:

Return value

object

1 string reference to 'location_feeds_set_target'
_location_feeds_fill_targets in ./location_feeds.module
Helper function to add target fields

File

./location_feeds.module, line 155
This module provides location mappers to feed importers.

Code

function location_feeds_set_target($object, $target, $value) {
  list($field_name, $sub_field) = explode(':', $target);
  if (strpos($sub_field, '][') !== FALSE) {
    list($sub_field, $last_field) = explode('][', $sub_field, 2);
  }
  if (!is_array($value)) {
    $value = array(
      $value,
    );
  }
  foreach ($value as $i => $val) {
    $val = trim($val);
    if (isset($last_field)) {
      $object->{$field_name}[$i][$sub_field][$last_field] = $val;
    }
    else {
      $object->{$field_name}[$i][$sub_field] = $val;
    }
  }
  return $object;
}