Commit 3759cbd3 authored by davisben's avatar davisben
Browse files

Issue #1901386 by tripper54: Feeds support.

parent 0824017f
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
@@ -374,6 +374,41 @@ function weight_menu_link_update($link) {
  _weight_set_weight_from_menu_link($link);
}

/**
 * Implements hook_feeds_processor_targets_alter()
 */
function weight_feeds_processor_targets_alter(&$targets, $entity_type, $bundle_name) {
  if ($entity_type == 'node') {
    $settings = _weight_get_settings($bundle_name);
    if (!empty($settings) && ($settings['enabled'])) {
      $targets['weight'] = array(
        'name' => t('Weight'),
        'callback' => 'weight_feeds_set_target',
        'description' => t('The weight of the node.'),
      );
    }
  }
}

/**
 * Callback for mapping weights.
 *
 * @param $source
 *   Field mapper source settings.
 * @param $entity
 *   An entity object, for instance a node object.
 * @param $target
 *   A string identifying the target on the node.
 * @param $value
 *   The value to populate the target with.
 * @param $mapping
 *  Associative array of the mapping settings from the per mapping
 *  configuration form.
 */
function weight_feeds_set_target($source, $entity, $target, $value) {
  $entity->weight_weight = $value;
}

/**
 * Implements hook_features_api().
 */