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

View File

@ -100,6 +100,10 @@ class CsvImporter implements ImporterInterface
$object->setUser($this->job->user);
$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.
foreach ($config['specifics'] as $name => $enabled) {
/** @var SpecificInterface $specific */