Extend ImportObject with row hash.

This commit is contained in:
James Cole 2016-08-14 08:34:51 +02:00
parent e440d55034
commit 117bb602dc
2 changed files with 10 additions and 0 deletions

View File

@ -32,6 +32,8 @@ class ImportEntry
public $externalID; public $externalID;
/** @var array */ /** @var array */
public $fields = []; public $fields = [];
/** @var string */
public $hash;
/** @var User */ /** @var User */
public $user; public $user;
/** @var bool */ /** @var bool */
@ -77,6 +79,10 @@ class ImportEntry
default: default:
Log::error('Import entry cannot handle object.', ['role' => $role]); Log::error('Import entry cannot handle object.', ['role' => $role]);
throw new FireflyException('Import entry cannot handle object of type "' . $role . '".'); throw new FireflyException('Import entry cannot handle object of type "' . $role . '".');
case 'hash':
$this->hash = $convertedValue;
return;
case 'amount': case 'amount':
/* /*
* Easy enough. * Easy enough.

View File

@ -100,6 +100,10 @@ class CsvImporter implements ImporterInterface
$object->setUser($this->job->user); $object->setUser($this->job->user);
$config = $this->job->configuration; $config = $this->job->configuration;
// hash the row:
$hash = hash('sha256', json_encode($row));
$object->importValue('hash', 100, $hash);
// and this is the point where the specifix go to work. // and this is the point where the specifix go to work.
foreach ($config['specifics'] as $name => $enabled) { foreach ($config['specifics'] as $name => $enabled) {
/** @var SpecificInterface $specific */ /** @var SpecificInterface $specific */