function field_collection_feeds_processor_targets_alter in Field collection 7
Implements hook_feeds_processor_targets_alter().
File
- ./
field_collection.module, line 2230 - Module implementing field collection field type.
Code
function field_collection_feeds_processor_targets_alter(&$targets, $entity_type, $bundle_name) {
// Load up.
$loaded =& drupal_static(__FUNCTION__, FALSE);
if (!$loaded) {
$loaded = TRUE;
$path = drupal_get_path('module', 'feeds') . '/mappers';
$files = drupal_system_listing('/.*\\.inc$/', $path, 'name', 0);
foreach ($files as $file) {
if (strpos($file->uri, '/mappers/') !== FALSE) {
require_once DRUPAL_ROOT . '/' . $file->uri;
}
}
}
foreach (field_info_instances($entity_type, $bundle_name) as $name => $instance) {
$info = field_info_field($name);
if ($info['type'] === 'field_collection') {
$sub_type = 'field_collection_item';
$new_targets = module_invoke_all('feeds_processor_targets', $sub_type, $info['field_name']);
drupal_alter('feeds_processor_targets', $new_targets, $sub_type, $info['field_name']);
foreach ($new_targets as $sub_name => $target) {
$new_name = t($info['field_name']) . ':' . t($sub_name);
$targets[$new_name] = $target;
if (isset($target['name'])) {
$targets[$new_name]['name'] = $instance['label'] . ':' . $target['name'];
}
// We override callback for now and retrieve original later.
$targets[$new_name]['callback'] = 'field_collection_feeds_set_target';
}
}
}
}