Skip to content

Commit 52efc46

Browse files
authored
IBX-7979: Fixed "field" occurrences in fields' identifiers being wrongly replaced (#61)
1 parent af1ed63 commit 52efc46

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/lib/Schema/Domain/Content/Mapper/FieldDefinition/ResolverVariables.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,27 @@ public function mapToFieldValueResolver(FieldDefinition $fieldDefinition): strin
3939
{
4040
$resolver = $this->innerMapper->mapToFieldValueResolver($fieldDefinition);
4141

42+
//we make sure no "field" (case insensitive) keyword in the actual field's identifier gets replaced
43+
//only syntax like: '@=resolver("MatrixFieldValue", [value, "field_matrix"])' needs to be taken into account
44+
//where [value, "field_matrix"] stands for the actual field's identifier
45+
if (preg_match('/value, "(.*field.*)"/i', $resolver) !== 1) {
46+
$resolver = str_replace(
47+
'field',
48+
'resolver("ItemFieldValue", [value, "' . $fieldDefinition->identifier . '", args])',
49+
$resolver
50+
);
51+
}
52+
4253
return str_replace(
4354
[
4455
'content',
4556
'location',
4657
'item',
47-
'field',
4858
],
4959
[
5060
'value.getContent()',
5161
'value.getLocation()',
5262
'value',
53-
'resolver("ItemFieldValue", [value, "' . $fieldDefinition->identifier . '", args])',
5463
],
5564
$resolver
5665
);

0 commit comments

Comments
 (0)