function entityreference_autocreate_feeds_processor_targets_alter in Entityreference Autocreate 7
Announce that we know how to set data on an entityreference field.
Given a list of target fields, find any entityreferences and attach ourselves as a handler callback for setting values.
If the entityreference widget settings have this option on already, that is.
Implements hook_feeds_processor_targets_alter().
See also
FeedsNodeProcessor::getMappingTargets()
File
- ./
entityreference_autocreate.feeds.inc, line 31 - Feeds mapping implementation for the Entity reference module.
Code
function entityreference_autocreate_feeds_processor_targets_alter(&$targets, $entity_type, $bundle_name) {
// This only ever gets called when you visit the UI
// admin/structure/feeds/{feed_name}/mapping
foreach (field_info_instances($entity_type, $bundle_name) as $name => $instance) {
$field_info = field_info_field($name);
if ($field_info['type'] == 'entityreference') {
// Check if the UI option is on also.
if (empty($instance['widget']['settings']['entityreference_autocreate'])) {
continue;
}
$targets[$name] = array(
'name' => t('!label by title lookup (creating if needed)', array(
'!label' => check_plain($instance['label']),
)),
'callback' => 'entityreference_autocreate_feeds_set_target',
'description' => t('The field instance @label of @id', array(
'@label' => $instance['label'],
'@id' => $name,
)),
);
}
}
}