Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-7979: Fixed "field" keyword occurrences in fields' identifiers being wrongly replaced #61

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading