Skip to content

Commit

Permalink
SOE-3326 Fix wildcard tampers (#186)
Browse files Browse the repository at this point in the history
  • Loading branch information
pookmish authored and boznik committed Aug 31, 2018
1 parent 7cca42a commit 3808aa7
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions modules/capx_tamper/capx_tamper.module
Original file line number Diff line number Diff line change
Expand Up @@ -428,20 +428,8 @@ function capx_tamper_alter_data($entity, &$data, $field_name) {
$items = array();
foreach (capx_tamper_get_mapper_sources($cfe_mapper) as $path) {
$item = $mapper->getRemoteDataByJsonPath($data, $path);
if (strpos($path, '*') !== FALSE) {
$index = $mapper->getIndex();
if (isset($item[$index])) {
$item = $item[$index];
}
}

if (is_array($item)) {
if (array_filter($item)) {
$item = reset($item);
}
else {
$item = NULL;
}
if (!is_array($item)) {
$item = [$item];
}
$items[0][$path] = $item;
}
Expand All @@ -461,12 +449,15 @@ function capx_tamper_alter_data($entity, &$data, $field_name) {
// the feeds tamper plugin directly.
$pre_callback = 'capx_tamper_' . $plugin['callback'];
$key = 0;
if (function_exists($pre_callback)) {
$pre_callback($result, $key, $path, $field, $tamper->settings, $tamper->source);
foreach ($field as $delta => &$field_data) {
if (function_exists($pre_callback)) {
$pre_callback($result, $key, $path, $field_data, $tamper->settings, $tamper->source);
}
// Call the feeds tamper. Then set that value back into the data array.
$plugin['callback']($result, $key, $path, $field_data, $tamper->settings, $tamper->source);

capx_tamper_set_data_by_json_path($data, $path, $field_data, $delta);
}
// Call the feeds tamper. Then set that value back into the data array.
$plugin['callback']($result, $key, $path, $field, $tamper->settings, $tamper->source);
capx_tamper_set_data_by_json_path($data, $path, $field, $mapper->getIndex());
}
}
}
Expand Down

0 comments on commit 3808aa7

Please sign in to comment.