Skip to content

MQE-910: [GitHub] The property of the parent element is used first when making a request #250

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

Merged
merged 6 commits into from
Nov 27, 2018
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 @@ -197,15 +197,33 @@ private function resolveUrlReference($urlIn, $entityObjects)
{
$urlOut = $urlIn;
$matchedParams = [];
// Find all the params ({}) references
preg_match_all("/[{](.+?)[}]/", $urlIn, $matchedParams);

if (!empty($matchedParams)) {
foreach ($matchedParams[0] as $paramKey => $paramValue) {
$paramEntityParent = "";
$matchedParent = [];
$dataItem = $matchedParams[1][$paramKey];
// Find all the parent property (Type.key) references, assuming there will be only one
// parent property reference within one param
preg_match_all("/(.+?)\./", $dataItem, $matchedParent);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment:
Try to find "type." in "type.field"


if (!empty($matchedParent) && !empty($matchedParent[0])) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment:
Assign entity "type" for filtering, remove "type." from parameter

$paramEntityParent = $matchedParent[1][0];
$dataItem = preg_replace('/^'.$matchedParent[0][0].'/', '', $dataItem);
}

foreach ($entityObjects as $entityObject) {
$param = $entityObject->getDataByName(
$matchedParams[1][$paramKey],
EntityDataObject::CEST_UNIQUE_VALUE
);
$param = null;

if ($paramEntityParent === "" || $entityObject->getType() == $paramEntityParent) {
$param = $entityObject->getDataByName(
$dataItem,
EntityDataObject::CEST_UNIQUE_VALUE
);
}

if (null !== $param) {
$urlOut = str_replace($paramValue, $param, $urlOut);
continue;
Expand Down