Skip to content

Commit

Permalink
IBX-7979: Fixed "field" occurrences in fields' identifiers being wron…
Browse files Browse the repository at this point in the history
…gly replaced
  • Loading branch information
konradoboza committed Apr 8, 2024
1 parent af1ed63 commit f8f33a6
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,27 @@ public function mapToFieldValueResolver(FieldDefinition $fieldDefinition): strin
{
$resolver = $this->innerMapper->mapToFieldValueResolver($fieldDefinition);

//we make sure no "field" (case insensitive) keyword in the actual field's identifier gets replaced
//only syntax like: '@=resolver("MatrixFieldValue", [value, "field_matrix"])' needs to be taken into account
//where [value, "field_matrix"] stands for the actual field's identifier
if (preg_match('/value, "(.*field.*)"/i', $resolver) !== 1) {
$resolver = 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 f8f33a6

Please sign in to comment.