mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 23:45:10 +00:00
This fixes the tests (must still upload test database).
This commit is contained in:
@@ -77,7 +77,9 @@ class Import extends Command
|
||||
$handler = new CommandHandler($this);
|
||||
$monolog->pushHandler($handler);
|
||||
|
||||
$routine = new ImportRoutine($job);
|
||||
/** @var ImportRoutine $routine */
|
||||
$routine = app(ImportRoutine::class);
|
||||
$routine->setJob($job);
|
||||
$routine->run();
|
||||
|
||||
/** @var MessageBag $error */
|
||||
|
@@ -243,7 +243,9 @@ class ImportController extends Controller
|
||||
*/
|
||||
public function start(ImportJob $job)
|
||||
{
|
||||
$routine = new ImportRoutine($job);
|
||||
/** @var ImportRoutine $routine */
|
||||
$routine = app(ImportRoutine::class);
|
||||
$routine->setJob($job);
|
||||
$result = $routine->run();
|
||||
if ($result) {
|
||||
return Response::json(['run' => 'ok']);
|
||||
@@ -281,9 +283,12 @@ class ImportController extends Controller
|
||||
$key = sprintf('firefly.import_configurators.%s', $type);
|
||||
$className = config($key);
|
||||
if (is_null($className)) {
|
||||
throw new FireflyException('Cannot find configurator class for this job.');
|
||||
throw new FireflyException('Cannot find configurator class for this job.'); // @codeCoverageIgnore
|
||||
}
|
||||
$configurator = new $className($job);
|
||||
/** @var ConfiguratorInterface $configurator */
|
||||
$configurator = app($className);
|
||||
$configurator->setJob($job);
|
||||
|
||||
|
||||
return $configurator;
|
||||
}
|
||||
|
@@ -22,10 +22,8 @@ interface ConfiguratorInterface
|
||||
{
|
||||
/**
|
||||
* ConfiguratorInterface constructor.
|
||||
*
|
||||
* @param ImportJob $job
|
||||
*/
|
||||
public function __construct(ImportJob $job);
|
||||
public function __construct();
|
||||
|
||||
/**
|
||||
* Store any data from the $data array into the job.
|
||||
@@ -36,6 +34,13 @@ interface ConfiguratorInterface
|
||||
*/
|
||||
public function configureJob(array $data): bool;
|
||||
|
||||
/**
|
||||
* @param ImportJob $job
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setJob(ImportJob $job);
|
||||
|
||||
/**
|
||||
* Return the data required for the next step in the job configuration.
|
||||
*
|
||||
|
@@ -28,14 +28,11 @@ class CsvConfigurator implements ConfiguratorInterface
|
||||
{
|
||||
private $job;
|
||||
|
||||
public function __construct(ImportJob $job)
|
||||
/**
|
||||
* ConfiguratorInterface constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->job = $job;
|
||||
if (is_null($this->job->configuration) || count($this->job->configuration) === 0) {
|
||||
Log::debug(sprintf('Gave import job %s initial configuration.', $this->job->key));
|
||||
$this->job->configuration = config('csv.default_config');
|
||||
$this->job->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,6 +113,19 @@ class CsvConfigurator implements ConfiguratorInterface
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ImportJob $job
|
||||
*/
|
||||
public function setJob(ImportJob $job)
|
||||
{
|
||||
$this->job = $job;
|
||||
if (is_null($this->job->configuration) || count($this->job->configuration) === 0) {
|
||||
Log::debug(sprintf('Gave import job %s initial configuration.', $this->job->key));
|
||||
$this->job->configuration = config('csv.default_config');
|
||||
$this->job->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws FireflyException
|
||||
|
@@ -37,16 +37,23 @@ class ImportRoutine
|
||||
/**
|
||||
* ImportRoutine constructor.
|
||||
*
|
||||
* @param ImportJob $job
|
||||
*/
|
||||
public function __construct(ImportJob $job)
|
||||
public function __construct()
|
||||
{
|
||||
$this->job = $job;
|
||||
$this->journals = new Collection;
|
||||
$this->errors = new Collection;
|
||||
Log::debug(sprintf('Job ID is #%d', $job->id));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ImportJob $job
|
||||
*/
|
||||
public function setJob(ImportJob $job)
|
||||
{
|
||||
$this->job = $job;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
Reference in New Issue
Block a user