You are here

protected function FeedsProcessor::mapToTarget in Feeds 7.2

Maps values onto the target item.

Parameters

FeedsSource $source: The feed source.

mixed &$target_item: The target item to apply values into.

mixed $value: A value, or a list of values.

array $mapping: The mapping configuration.

1 call to FeedsProcessor::mapToTarget()
FeedsProcessor::map in plugins/FeedsProcessor.inc
Execute mapping on an item.

File

plugins/FeedsProcessor.inc, line 942
Contains FeedsProcessor and related classes.

Class

FeedsProcessor
Abstract class, defines interface for processors.

Code

protected function mapToTarget(FeedsSource $source, $target, &$target_item, $value, array $mapping) {
  $targets = $this
    ->getCachedTargets();

  // Map the source element's value to the target.
  // If the mapping specifies a callback method, use the callback instead of
  // setTargetElement().
  if (isset($targets[$target]['callback'])) {

    // All target callbacks expect an array.
    if (!is_array($value)) {
      $value = array(
        $value,
      );
    }
    call_user_func($targets[$target]['callback'], $source, $target_item, $target, $value, $mapping);
  }
  else {
    $this
      ->setTargetElement($source, $target_item, $target, $value, $mapping);
  }
}