You are here

function mvf_feeds_processor_targets in Measured Value Field 7

Implements hook_feeds_processor_targets().

File

./mvf.feeds.inc, line 11
Integration with Feeds of MVF module.

Code

function mvf_feeds_processor_targets($entity_type, $bundle) {
  $targets = array();
  $mvf_types = mvf_field_types();
  foreach (field_info_instances($entity_type, $bundle) as $field_name => $instance) {
    $field = field_info_field($field_name);
    if (in_array($field['type'], $mvf_types)) {
      $targets[$field_name] = array(
        'name' => check_plain($instance['label']),
        'callback' => 'mvf_feeds_set_target',
        'description' => t('The @label field of the entity in format "123.45 [unit]".', array(
          '@label' => $instance['label'],
        )),
        'form_callbacks' => array(
          'mvf_feeds_unit_notation_form_callback',
        ),
        'summary_callbacks' => array(
          'mvf_feeds_unit_notation_summary_callback',
        ),
      );
      $targets[$field_name . ':value'] = array(
        'name' => t('@field value', array(
          '@field' => check_plain($instance['label']),
        )),
        'callback' => 'mvf_feeds_set_target',
        'description' => t('The @label field value of the entity in format "123.45".', array(
          '@label' => $instance['label'],
        )),
        'real_target' => $field_name,
      );
      $targets[$field_name . ':unit'] = array(
        'name' => t('@field unit', array(
          '@field' => check_plain($instance['label']),
        )),
        'callback' => 'mvf_feeds_set_target',
        'description' => t('The @label field unit of the entity.', array(
          '@label' => $instance['label'],
        )),
        'form_callbacks' => array(
          'mvf_feeds_unit_notation_form_callback',
        ),
        'summary_callbacks' => array(
          'mvf_feeds_unit_notation_summary_callback',
        ),
        'real_target' => $field_name,
      );
    }
  }
  return $targets;
}