You are here

function node_reference_feeds_processor_targets_alter in References 7.2

Implements hook_feeds_processor_targets_alter() for node_reference fields.

See also

FeedsNodeProcessor::getMappingTargets()

File

./references.feeds.inc, line 68
References Feed File.

Code

function node_reference_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);
    if ($info['type'] == 'node_reference') {
      $targets[$name . ':title'] = array(
        'name' => t('@label (Node reference by node title)', array(
          '@label' => $instance['label'],
        )),
        'callback' => 'references_feeds_set_target',
        'description' => t('The @label field of the node matched by node title.', array(
          '@label' => $instance['label'],
        )),
        'real_target' => $name,
      );
      $targets[$name . ':nid'] = array(
        'name' => t('@label (Node reference by node ID)', array(
          '@label' => $instance['label'],
        )),
        'callback' => 'references_feeds_set_target',
        'description' => t('The @label field of the node matched by node ID.', array(
          '@label' => $instance['label'],
        )),
        'real_target' => $name,
      );
      $targets[$name . ':url'] = array(
        'name' => t('@label (Node reference by Feeds URL)', array(
          '@label' => $instance['label'],
        )),
        'callback' => 'references_feeds_set_target',
        'description' => t('The @label field of the node matched by Feeds URL.', array(
          '@label' => $instance['label'],
        )),
        'real_target' => $name,
      );
      $targets[$name . ':guid'] = array(
        'name' => t('@label (Node reference by Feeds GUID)', array(
          '@label' => $instance['label'],
        )),
        'callback' => 'references_feeds_set_target',
        'description' => t('The @label field of the node matched by Feeds GUID.', array(
          '@label' => $instance['label'],
        )),
        'real_target' => $name,
      );
      $targets[$name . ':title:duplicates'] = array(
        'name' => t('@label (Node reference by node title) -- allow duplicate nodes', array(
          '@label' => $instance['label'],
        )),
        'callback' => 'references_feeds_set_target',
        'description' => t('The @label field of the node matched by node title. This target allows duplicate nodes (nodes can appear more than once in a field).', array(
          '@label' => $instance['label'],
        )),
        'real_target' => $name,
      );
      $targets[$name . ':nid:duplicates'] = array(
        'name' => t('@label (Node reference by node ID) -- allow duplicate nodes', array(
          '@label' => $instance['label'],
        )),
        'callback' => 'references_feeds_set_target',
        'description' => t('The @label field of the node matched by node ID. This target allows duplicate nodes (nodes can appear more than once in a field).', array(
          '@label' => $instance['label'],
        )),
        'real_target' => $name,
      );
      $targets[$name . ':url:duplicates'] = array(
        'name' => t('@label (Node reference by Feeds URL) -- allow duplicate nodes', array(
          '@label' => $instance['label'],
        )),
        'callback' => 'references_feeds_set_target',
        'description' => t('The @label field of the node matched by Feeds URL.', array(
          '@label' => $instance['label'],
        )),
        'real_target' => $name,
      );
      $targets[$name . ':guid:duplicates'] = array(
        'name' => t('@label (Node reference by Feeds GUID) -- allow duplicate nodes', array(
          '@label' => $instance['label'],
        )),
        'callback' => 'references_feeds_set_target',
        'description' => t('The @label field of the node matched by Feeds GUID.', array(
          '@label' => $instance['label'],
        )),
        'real_target' => $name,
      );
    }
  }
}