ImportExport: return number of imported objects

This commit is contained in:
Thomas Gelf 2018-06-14 13:43:52 +02:00
parent 1ca41c5b10
commit 17321e4a5f

View File

@ -103,19 +103,27 @@ class ImportExport
public function unserializeImportSources($objects) public function unserializeImportSources($objects)
{ {
$this->connection->runFailSafeTransaction(function () use ($objects) { $count = 0;
$this->connection->runFailSafeTransaction(function () use ($objects, & $count) {
foreach ($objects as $object) { foreach ($objects as $object) {
ImportSource::import($object, $this->connection)->store(); ImportSource::import($object, $this->connection)->store();
$count++;
} }
}); });
return $count;
} }
public function unserializeSyncRules($objects) public function unserializeSyncRules($objects)
{ {
$this->connection->runFailSafeTransaction(function () use ($objects) { $count = 0;
$this->connection->runFailSafeTransaction(function () use ($objects, & $count) {
foreach ($objects as $object) { foreach ($objects as $object) {
SyncRule::import($object, $this->connection)->store(); SyncRule::import($object, $this->connection)->store();
} }
$count++;
}); });
return $count;
} }
} }