Update collector classes

This commit is contained in:
James Cole 2017-02-05 15:58:55 +01:00
parent 371ce37be4
commit 704c0922e8
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
4 changed files with 26 additions and 21 deletions

View File

@ -43,10 +43,8 @@ class AttachmentCollector extends BasicCollector implements CollectorInterface
/**
* AttachmentCollector constructor.
*
* @param ExportJob $job
*/
public function __construct(ExportJob $job)
public function __construct()
{
/** @var AttachmentRepositoryInterface repository */
$this->repository = app(AttachmentRepositoryInterface::class);
@ -54,7 +52,7 @@ class AttachmentCollector extends BasicCollector implements CollectorInterface
$this->uploadDisk = Storage::disk('upload');
$this->exportDisk = Storage::disk('export');
parent::__construct($job);
parent::__construct();
}
/**

View File

@ -31,13 +31,10 @@ class BasicCollector
/**
* BasicCollector constructor.
*
* @param ExportJob $job
*/
public function __construct(ExportJob $job)
public function __construct()
{
$this->entries = new Collection;
$this->job = $job;
}
/**
@ -56,5 +53,13 @@ class BasicCollector
$this->entries = $entries;
}
/**
* @param ExportJob $job
*/
public function setJob(ExportJob $job)
{
$this->job = $job;
}
}

View File

@ -13,6 +13,7 @@ declare(strict_types = 1);
namespace FireflyIII\Export\Collector;
use FireflyIII\Models\ExportJob;
use Illuminate\Support\Collection;
/**
@ -32,6 +33,13 @@ interface CollectorInterface
*/
public function run(): bool;
/**
* @param ExportJob $job
*
* @return mixed
*/
public function setJob(ExportJob $job);
/**
* @param Collection $entries
*

View File

@ -14,7 +14,6 @@ declare(strict_types = 1);
namespace FireflyIII\Export\Collector;
use Crypt;
use FireflyIII\Models\ExportJob;
use Illuminate\Contracts\Encryption\DecryptException;
use Log;
use Storage;
@ -35,22 +34,12 @@ class UploadCollector extends BasicCollector implements CollectorInterface
/**
* AttachmentCollector constructor.
*
* @param ExportJob $job
*/
public function __construct(ExportJob $job)
public function __construct()
{
parent::__construct($job);
Log::debug('Going to collect attachments', ['key' => $job->key]);
// make storage:
parent::__construct();
$this->uploadDisk = Storage::disk('upload');
$this->exportDisk = Storage::disk('export');
// file names associated with the old import routine.
$this->vintageFormat = sprintf('csv-upload-%d-', auth()->user()->id);
}
/**
@ -60,6 +49,11 @@ class UploadCollector extends BasicCollector implements CollectorInterface
*/
public function run(): bool
{
Log::debug('Going to collect attachments', ['key' => $this->job->key]);
// file names associated with the old import routine.
$this->vintageFormat = sprintf('csv-upload-%d-', $this->job->user->id);
// collect old upload files (names beginning with "csv-upload".
$this->collectVintageUploads();