Skip to content

Commit

Permalink
Merge pull request #110 from ConductionNL/development
Browse files Browse the repository at this point in the history
Dev to main
  • Loading branch information
bbrands02 authored Dec 2, 2024
2 parents 81ea336 + 0c61bc0 commit 53e4195
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"category": "d.woo_x005f_categorie",
"published": "{% if d['woo_x005f_publicatiedatum']|default %}{{ d['woo_x005f_publicatiedatum']|date('Y-m-d') }}{% endif %}",
"modified": "d.vti_x005f_nexttolasttimemodified",
"attachments": "{{ '[' }}{% if fileUrls['d']['results']|default %}{% set index = 0 %}{% for file in fileUrls['d']['results'] %}{% if index > 0 %}{{ ', ' }}{% endif %}{{ '{' }}{% if file['Name']|default %} \"title\": \"{{ file['Name'] }}\",{% endif %} \"downloadUrl\": {{ '{' }}{% set uri = file['__metadata']['uri']~'/$value' %}{{ '\"downloadUrl\": \"'~uri~'\",\"source\": \"1\"' }}{{ '}' }}{{ '}' }}{% endfor %}{% endif %}{{ ']' }}",
"attachments": "[ {% for file in fileUrls %} { {% if file['Name']|default %}\"title\": \"{{ file['Name'] }}\",{% endif %}{% if file['d']['document_x005f_label']|default %}\"labels\": [\"{{ file['d']['document_x005f_label'] }}\"],{% endif %}{% if file['__metadata']['uri']|default %}\"downloadUrl\": {\"downloadUrl\": \"{{ file['__metadata']['uri']~'/$value' }}\", \"source\": \"1\"}{% endif %} }{{ loop.last ? '' : ',' }} {% endfor %} ]",
"status": "{% if d['woo_x005f_publicatiedatum']|default %}Published{% else %}Concept{% endif %}",
"catalog": ""
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
"extraDataConfigs.1.dynamicEndpointLocation": "Files.__deferred.uri",
"extraDataConfigs.1.mergeExtraData": "true",
"extraDataConfigs.1.keyToSetExtraData": "fileUrls",
"extraDataConfigs.1.resultsLocation": "d.results",
"extraDataConfigs.1.extraDataConfigPerResult.dynamicEndpointLocation": "Properties.__deferred.uri",
"extraDataConfigs.1.extraDataConfigPerResult.mergeExtraData": "true",
"headers": [],
"query": []
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
"extraDataConfigs.1.dynamicEndpointLocation": "Files.__deferred.uri",
"extraDataConfigs.1.mergeExtraData": "true",
"extraDataConfigs.1.keyToSetExtraData": "fileUrls",
"extraDataConfigs.1.resultsLocation": "d.results",
"extraDataConfigs.1.extraDataConfigPerResult.dynamicEndpointLocation": "Properties.__deferred.uri",
"extraDataConfigs.1.extraDataConfigPerResult.mergeExtraData": "true",
"headers": [],
"query": []
},
Expand Down
15 changes: 13 additions & 2 deletions lib/Service/SynchronizationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,25 @@ private function fetchExtraDataForObject(Synchronization $synchronization, array

$extraData = $this->getObjectFromSource($synchronization, $endpoint);

// Temporary fix,
if ($extraDataConfig['extraDataConfigPerResult']) {
$dotObject = new Dot($extraData);
$results = $dotObject->get($extraDataConfig['resultsLocation']);

foreach ($results as $key => $result) {
$results[$key] = $this->fetchExtraDataForObject($synchronization, $extraDataConfig['extraDataConfigPerResult'], $result);
}

$extraData = $results;
}

// Set new key if configured.
if (isset($extraDataConfig[$this::KEY_FOR_EXTRA_DATA_LOCATION]) === true) {
$extraData = [$extraDataConfig[$this::KEY_FOR_EXTRA_DATA_LOCATION] => $extraData];
}

// Merge with earlier fetchde object if configured.
if (isset($extraDataConfig[$this::MERGE_EXTRA_DATA_OBJECT_LOCATION]) === true && $extraDataConfig[$this::MERGE_EXTRA_DATA_OBJECT_LOCATION] === true) {
if (isset($extraDataConfig[$this::MERGE_EXTRA_DATA_OBJECT_LOCATION]) === true && ($extraDataConfig[$this::MERGE_EXTRA_DATA_OBJECT_LOCATION] === true || $extraDataConfig[$this::MERGE_EXTRA_DATA_OBJECT_LOCATION] === 'true')) {
return array_merge($object, $extraData);
}

Expand Down Expand Up @@ -347,7 +359,6 @@ public function synchronizeContract(SynchronizationContract $synchronizationCont
}
}


// set the target hash
$targetHash = md5(serialize($targetObject));
$synchronizationContract->setTargetHash($targetHash);
Expand Down

0 comments on commit 53e4195

Please sign in to comment.