public function MigrateGeolocationFieldHandler::prepare in Geolocation Field 7
File
- migrate/
destinations/ geolocation.inc, line 63 - Contains geolocation field migration handler.
Class
- MigrateGeolocationFieldHandler
- Geolocation field migration handler class.
Code
public function prepare($entity, array $field_info, array $instance, array $values) {
$arguments = isset($values['arguments']) ? $values['arguments'] : array();
$arguments += array(
'lat' => array(),
'lng' => array(),
);
// When a single value is mapped to an argument, Migrate module doesn't wrap
// it in array.
foreach (array(
'lat',
'lng',
) as $subelement) {
if (!is_array($arguments[$subelement])) {
$arguments[$subelement] = array(
$arguments[$subelement],
);
}
}
$return = array();
foreach ($arguments['lat'] as $delta => $value) {
$item = array(
'lat' => $arguments['lat'][$delta],
'lng' => isset($arguments['lng'][$delta]) ? $arguments['lng'][$delta] : NULL,
);
if ($this
->validate($entity, $field_info, $instance, $item)) {
$language = $this
->getGeolocationFieldLanguage($entity, $field_info, $arguments, $delta);
$return[$language][] = _geolocation_field_precalculate_values($item);
}
}
return !empty($return) ? $return : NULL;
}