Sync: retrieve import format

This commit is contained in:
Thomas Gelf 2015-08-28 23:52:02 +02:00
parent c456f79c4c
commit 8ccad501e8
2 changed files with 13 additions and 0 deletions

View File

@ -213,6 +213,7 @@ class Db extends DbConnection
array('rp' => 'imported_row_property'), array('rp' => 'imported_row_property'),
array( array(
'property_value' => 'p.property_value', 'property_value' => 'p.property_value',
'format' => 'p.format',
'row_checksum' => 'rp.row_checksum' 'row_checksum' => 'rp.row_checksum'
) )
)->join( )->join(
@ -228,6 +229,7 @@ class Db extends DbConnection
foreach ($columns as $c) { foreach ($columns as $c) {
$fetchColumns[$c] = sprintf('p_%s.property_value', $c); $fetchColumns[$c] = sprintf('p_%s.property_value', $c);
$fetchColumns[$c . '__f'] = sprintf('p_%s.format', $c);
$p = clone($propertyQuery); $p = clone($propertyQuery);
$query->joinLeft( $query->joinLeft(
array(sprintf('p_' . $c) => $p->where('p.property_name = ?', $c)), array(sprintf('p_' . $c) => $p->where('p.property_name = ?', $c)),

View File

@ -29,6 +29,17 @@ class Sync
protected function fillVariables($string, $row) protected function fillVariables($string, $row)
{ {
if (preg_match('/^\${([A-Za-z0-9_-]+)}$/', $string, $m)) {
$var = $m[1];
if (! property_exists($row, $var)) {
return null;
}
if ($row->{$var . '__f'} === 'json') {
return json_decode($row->$var);
}
return $row->$var;
}
$func = function ($match) use ($row) { $func = function ($match) use ($row) {
return $row->{$match[1]}; return $row->{$match[1]};
}; };