function feeds_para_mapper_set_value in Feeds Paragraphs 7
Sets the values for the target field.
Parameters
\FeedsSource $source: The source instance.
object $entity: The entity that is being edited or created.
\ParagraphsItemEntity $paragraph: The loaded or created Paragraphs entity.
array $mapping: Information about the target field and the target paragraph.
array $value: The source field value.
1 call to feeds_para_mapper_set_value()
- feeds_para_mapper_set_target in ./
feeds_para_mapper.module - Sets the values for the target field.
File
- ./
feeds_para_mapper.module, line 551 - Allows feeds to import content to Paragraphs' fields.
Code
function feeds_para_mapper_set_value(\FeedsSource $source, $entity, \ParagraphsItemEntity $paragraph, array $mapping, array $value) {
/*
Call the the field module to begin mapping.
Sometimes the field module sets a target different than the real target,
e.g 'target_field:sub_target',
in this case we need to pass the $mapping['target'] value.
*/
$correct_field = $mapping['field'];
$is_different = FALSE;
if ($mapping['field'] !== $mapping['target']) {
$correct_field = $mapping['target'];
$is_different = TRUE;
}
// Reset the values of the field:
if (!$entity->feeds_item->is_new && !$is_different) {
$field = $mapping['field'];
$lang = $mapping['language'];
$paragraph->{$field}[$lang] = array();
}
$args = array(
$source,
$paragraph,
$correct_field,
$value,
$mapping,
);
$function = $mapping['module_callback'];
call_user_func($function, $args[0], $args[1], $args[2], $args[3], $args[4]);
if (!$entity->feeds_item->is_new) {
feeds_para_mapper_append_to_update($entity, $mapping, $paragraph);
}
}