You are here

function date_feeds_set_target in Feeds 7

Same name and namespace in other branches
  1. 6 mappers/date.inc \date_feeds_set_target()
  2. 7.2 mappers/date.inc \date_feeds_set_target()

Implements hook_feeds_set_target().

@todo Support array of values for dates.

Parameters

$node: The target node.

$field_name: The name of field on the target node to map to.

$feed_element: The value to be mapped. Should be either a (flexible) date string or a FeedsDateTimeElement object.

1 string reference to 'date_feeds_set_target'
date_feeds_node_processor_targets_alter in mappers/date.inc
Implements hook_feeds_node_processor_targets_alter().

File

mappers/date.inc, line 51
On behalf implementation of Feeds mapping API for date

Code

function date_feeds_set_target($node, $target, $feed_element) {
  list($field_name, $sub_field) = split(':', $target);
  if (!$feed_element instanceof FeedsDateTimeElement) {
    if (is_array($feed_element)) {
      $feed_element = $feed_element[0];
    }
    if ($sub_field == 'end') {
      $feed_element = new FeedsDateTimeElement(NULL, $feed_element);
    }
    else {
      $feed_element = new FeedsDateTimeElement($feed_element, NULL);
    }
  }
  $feed_element
    ->buildDateField($node, $field_name);
}