function farm_livestock_feeds_importer_default_alter in farmOS 7
Implements hook_feeds_importer_default_alter().
File
- modules/
farm/ farm_livestock/ farm_livestock.module, line 139
Code
function farm_livestock_feeds_importer_default_alter($importers) {
// Add extra field mappings to animals.
$name = 'farm_asset_animal';
if (!empty($importers[$name])) {
$mappings = array(
array(
'source' => 'Nicknames',
'target' => 'field_farm_animal_nicknames',
'unique' => FALSE,
'language' => 'und',
),
array(
'source' => 'Date of birth',
'target' => 'field_farm_date:start',
'unique' => FALSE,
'language' => 'und',
),
array(
'source' => 'Species/breed',
'target' => 'field_farm_animal_type',
'term_search' => '0',
'autocreate' => 1,
'language' => 'und',
),
array(
'source' => 'Sex',
'target' => 'field_farm_animal_sex',
'unique' => FALSE,
'language' => 'und',
),
array(
'source' => 'Castrated',
'target' => 'field_farm_animal_castrated',
'unique' => FALSE,
'language' => 'und',
),
array(
'source' => 'Tag ID',
'target' => 'field_farm_animal_tag:field_farm_animal_tag_id',
'unique' => FALSE,
'language' => 'und',
),
array(
'source' => 'Tag type',
'target' => 'field_farm_animal_tag:field_farm_animal_tag_type',
'unique' => FALSE,
'language' => 'und',
),
array(
'source' => 'Tag location',
'target' => 'field_farm_animal_tag:field_farm_animal_tag_location',
'unique' => FALSE,
'language' => 'und',
),
);
$importer_mappings =& $importers[$name]->config['processor']['config']['mappings'];
$importer_mappings = array_merge($importer_mappings, $mappings);
}
// Add/alter field mappings on birth logs.
$name = 'log_farm_birth';
if (!empty($importers[$name])) {
// Add Mother ID and name mappings.
$mappings = array(
array(
'source' => 'Mother ID',
'target' => 'field_farm_mother:etid',
'unique' => FALSE,
'language' => 'und',
),
array(
'source' => 'Mother name',
'target' => 'field_farm_mother:label',
'unique' => FALSE,
'language' => 'und',
),
);
$importer_mappings =& $importers[$name]->config['processor']['config']['mappings'];
$importer_mappings = array_merge($importer_mappings, $mappings);
// Change "Asset IDs" to "Children IDs".
foreach ($importer_mappings as &$mapping) {
if ($mapping['source'] == 'Asset IDs') {
$mapping['source'] = 'Children IDs';
}
}
// Change "Asset names" to "Children names".
foreach ($importer_mappings as &$mapping) {
if ($mapping['source'] == 'Asset names') {
$mapping['source'] = 'Children names';
}
}
}
}