Skip to content

Commit

Permalink
IBX-7979: Fixed "field" occurrences being wrongly replaced (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
konradoboza authored Mar 19, 2024
1 parent 5aaf673 commit d34971b
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,25 @@ public function mapToFieldValueResolver(FieldDefinition $fieldDefinition): strin
{
$resolver = $this->innerMapper->mapToFieldValueResolver($fieldDefinition);

//making sure we won't be replacing "field" occurrences in the actual field's name
if (preg_match('/"(.*field.*)"/', $resolver) !== 1) {
return str_replace(
'field',
'resolver("ItemFieldValue", [value, "' . $fieldDefinition->identifier . '", args])',
$resolver
);
}

return str_replace(
[
'content',
'location',
'item',
'field',
],
[
'value.getContent()',
'value.getLocation()',
'value',
'resolver("ItemFieldValue", [value, "' . $fieldDefinition->identifier . '", args])',
],
$resolver
);
Expand Down

0 comments on commit d34971b

Please sign in to comment.