You are here

function callback_my_module_set_target in Feeds 7.2

Sets a value on a target.

Callback for hook_feeds_processor_targets().

This callback is specified on the 'callback' key of the target definition. A target can for example be a field or property on an entity.

Parameters

FeedsSource $source: Field mapper source settings.

object $entity: An entity object, for instance a node object.

string $target: A string identifying the target on the node.

array $values: The value to populate the target with.

array $mapping: Associative array of the mapping settings from the per mapping configuration form.

See also

hook_feeds_processor_targets()

Related topics

1 string reference to 'callback_my_module_set_target'
hook_feeds_processor_targets in ./feeds.api.php
Adds mapping targets for processors.

File

./feeds.api.php, line 465
Documentation of Feeds hooks.

Code

function callback_my_module_set_target(FeedsSource $source, $entity, $target, array $values, array $mapping) {
  $entity->{$target}[$entity->language][0]['value'] = reset($values);
  if (isset($source->importer->processor->config['input_format'])) {
    $entity->{$target}[$entity->language][0]['format'] = $source->importer->processor->config['input_format'];
  }
}