You are here

function phone_feeds_processor_targets_alter in Phone 7.2

Same name and namespace in other branches
  1. 7 phone.feeds.inc \phone_feeds_processor_targets_alter()

Implements hook_feeds_processor_targets_alter().

See also

FeedsNodeProcessor::getMappingTargets()

File

./phone.feeds.inc, line 12
Implements Feeds support for Phone fields.

Code

function phone_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'] == 'phone') {
      $targets[$name] = array(
        'name' => t('@name: Number (single field)', array(
          '@name' => $instance['label'],
        )),
        'callback' => 'phone_feeds_set_target',
        'description' => t('The @label field of the entity.  Use if the entire number (country code, number, and extension) are provided in a single field.', array(
          '@label' => $instance['label'],
        )),
      );
      if (array_key_exists('countrycode', $info['columns'])) {
        $targets[$name . ':countrycode'] = array(
          'name' => t('@name: Country Code', array(
            '@name' => $instance['label'],
          )),
          'callback' => 'phone_feeds_set_target',
          'description' => t('The country code for a @label field of the entity, providing the two-letter code of the phone number\'s country.', array(
            '@label' => $instance['label'],
          )),
          'real_target' => $name,
        );
      }
      if (array_key_exists('number', $info['columns'])) {
        $targets[$name . ':number'] = array(
          'name' => t('@name: Number', array(
            '@name' => $instance['label'],
          )),
          'callback' => 'phone_feeds_set_target',
          'description' => t('The national number for a @label field of the entity, without any country information or extension.', array(
            '@label' => $instance['label'],
          )),
          'real_target' => $name,
        );
      }
      if (array_key_exists('numbertype', $info['columns'])) {
        $targets[$name . ':numbertype'] = array(
          'name' => t('@name: Number type', array(
            '@name' => $instance['label'],
          )),
          'callback' => 'phone_feeds_set_target',
          'description' => t('The number type for a @label field of the entity, providing the hcard telephone type.', array(
            '@label' => $instance['label'],
          )),
          'real_target' => $name,
        );
      }
      if (array_key_exists('extension', $info['columns'])) {
        $targets[$name . ':extension'] = array(
          'name' => t('@name: Extension', array(
            '@name' => $instance['label'],
          )),
          'callback' => 'phone_feeds_set_target',
          'description' => t('The extension for a @label field of the entity.', array(
            '@label' => $instance['label'],
          )),
          'real_target' => $name,
        );
      }
    }
  }
}