Skip to content

Firefly III: a personal finances manager

Update collector classes

James Cole704c0922e863
diff --git a/app/Export/Collector/AttachmentCollector.php b/app/Export/Collector/AttachmentCollector.php
index e068f32585..810dc1db85 100644
--- a/app/Export/Collector/AttachmentCollector.php
+++ b/app/Export/Collector/AttachmentCollector.php
@@ -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();
}
/**
diff --git a/app/Export/Collector/BasicCollector.php b/app/Export/Collector/BasicCollector.php
index 4fd571c84d..c80e8ec280 100644
--- a/app/Export/Collector/BasicCollector.php
+++ b/app/Export/Collector/BasicCollector.php
@@ -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;
+ }
+
}
diff --git a/app/Export/Collector/CollectorInterface.php b/app/Export/Collector/CollectorInterface.php
index f1778e9adc..54a3fa88a1 100644
--- a/app/Export/Collector/CollectorInterface.php
+++ b/app/Export/Collector/CollectorInterface.php
@@ -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
*
diff --git a/app/Export/Collector/UploadCollector.php b/app/Export/Collector/UploadCollector.php
index 1895cb8a5e..35c2e75188 100644
--- a/app/Export/Collector/UploadCollector.php
+++ b/app/Export/Collector/UploadCollector.php
@@ -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();