Import/Sync: add support for 'import' fields

This commit is contained in:
Thomas Gelf 2015-08-03 13:39:55 +02:00
parent c26f2ed087
commit 19eec671f2
1 changed files with 13 additions and 1 deletions

View File

@ -90,6 +90,7 @@ class Sync
);
$newVars = array();
$imports = array();
foreach ($properties as $p) {
if ($p->source_id !== $sourceId) continue;
@ -100,7 +101,11 @@ class Sync
if (substr($prop, 0, 5) === 'vars.') {
$newVars[substr($prop, 5)] = $val;
} else {
$newProps[$prop] = $val;
if ($prop === 'import') {
$imports[] = $val;
} else {
$newProps[$prop] = $val;
}
}
}
@ -111,6 +116,9 @@ class Sync
foreach ($newVars as $prop => $var) {
$objects[$key]->vars()->$prop = $var;
}
if (! empty($imports)) {
$objects[$key]->imports()->set($imports);
}
break;
case 'merge':
@ -123,6 +131,10 @@ class Sync
// TODO: property merge policy
$object->vars()->$prop = $var;
}
if (! empty($imports)) {
// TODO: merge imports ?!
$objects[$key]->imports()->set($imports);
}
break;
default: