Skip to content
Snippets Groups Projects
Commit e2973d13 authored by twistor's avatar twistor Committed by Chris Leppanen
Browse files

Issue #1815070 by twistor, joelpittet: No more mapping for numeric (boolean,...

Issue #1815070 by twistor, joelpittet: No more mapping for numeric (boolean, decimal, integer, floats, and lists of them) fields
parent cb04a06b
No related branches found
No related tags found
No related merge requests found
<?php
/**
* @file
* On behalf implementation of Feeds mapping API for list.module.
*/
/**
* Implements hook_feeds_processor_targets_alter().
*
* @see FeedsProcessor::getMappingTargets()
*/
function list_feeds_processor_targets_alter(&$targets, $entity_type, $bundle_name) {
foreach (field_info_instances($entity_type, $bundle_name) as $name => $instance) {
$info = field_info_field($name);
switch ($info['type']) {
case 'list_integer':
case 'list_float':
$targets[$name] = array(
'name' => check_plain($instance['label']),
'callback' => 'number_feeds_set_target',
'description' => t('The @label field of the entity.', array('@label' => $instance['label'])),
);
break;
case 'list_boolean':
$targets[$name] = array(
'name' => check_plain($instance['label']),
'callback' => 'list_feeds_set_boolean_target',
'description' => t('The @label field of the entity.', array('@label' => $instance['label'])),
);
break;
case 'list_text':
$targets[$name] = array(
'name' => check_plain($instance['label']),
'callback' => 'text_feeds_set_target',
'description' => t('The @label field of the entity.', array('@label' => $instance['label'])),
);
break;
}
}
}
/**
* Callback for setting list_boolean fields.
*/
function list_feeds_set_boolean_target(FeedsSource $source, $entity, $target, array $values, array $mapping = array()) {
$field = isset($entity->$target) ? $entity->$target : array(LANGUAGE_NONE => array());
foreach ($values as $value) {
if (is_object($value) && ($value instanceof FeedsElement)) {
$value = $value->getValue();
}
$field[LANGUAGE_NONE][] = array('value' => (int) (bool) $value);
}
$entity->$target = $field;
}
......@@ -12,9 +12,6 @@
*/
function number_feeds_processor_targets_alter(&$targets, $entity_type, $bundle_name) {
$numeric_types = array(
'list_integer',
'list_float',
'list_boolean',
'number_integer',
'number_decimal',
'number_float',
......
......@@ -12,7 +12,6 @@
*/
function text_feeds_processor_targets_alter(&$targets, $entity_type, $bundle_name) {
$text_types = array(
'list_text',
'text',
'text_long',
'text_with_summary',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment