Skip to content

Commit

Permalink
IBX-8309: the order of str_replace execution has been changed to matc…
Browse files Browse the repository at this point in the history
…h what was before the changes
  • Loading branch information
mateuszdebinski committed May 17, 2024
1 parent 52efc46 commit e236fd0
Showing 1 changed file with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,7 @@ public function mapToFieldValueType(FieldDefinition $fieldDefinition): string
public function mapToFieldValueResolver(FieldDefinition $fieldDefinition): string
{
$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(
$resolver = str_replace(
[
'content',
'location',
Expand All @@ -63,6 +51,19 @@ public function mapToFieldValueResolver(FieldDefinition $fieldDefinition): strin
],
$resolver
);

//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 $resolver;
}

public function mapToFieldValueInputType(ContentType $contentType, FieldDefinition $fieldDefinition): ?string
Expand Down

0 comments on commit e236fd0

Please sign in to comment.