From 5f5e691dfdd4d67e2c5fba30327416b259a8c8a4 Mon Sep 17 00:00:00 2001 From: konradoboza Date: Mon, 18 Mar 2024 12:09:47 +0100 Subject: [PATCH] IBX-7979: Fixed "field" occurrences being wrongly replaced --- .../Mapper/FieldDefinition/ResolverVariables.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lib/Schema/Domain/Content/Mapper/FieldDefinition/ResolverVariables.php b/src/lib/Schema/Domain/Content/Mapper/FieldDefinition/ResolverVariables.php index 8ccb12b..7ae00d0 100644 --- a/src/lib/Schema/Domain/Content/Mapper/FieldDefinition/ResolverVariables.php +++ b/src/lib/Schema/Domain/Content/Mapper/FieldDefinition/ResolverVariables.php @@ -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 );