. */ declare(strict_types=1); namespace FireflyIII\Http\Controllers\Import; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Http\Controllers\Controller; use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface; use FireflyIII\Support\Import\Prerequisites\PrerequisitesInterface; /** * Class BankController */ class BankController extends Controller { /** * Once there are no prerequisites, this method will create an importjob object and * redirect the user to a view where this object can be used by a bank specific * class to process. * * @param ImportJobRepositoryInterface $repository * @param string $bank * * @return \Illuminate\Http\RedirectResponse|null * @throws FireflyException */ public function createJob(ImportJobRepositoryInterface $repository, string $bank) { $class = config(sprintf('firefly.import_pre.%s', $bank)); if (!class_exists($class)) { throw new FireflyException(sprintf('Cannot find class %s', $class)); } $importJob = $repository->create($bank); $config = $importJob->configuration; $config['has-config-file'] = false; $config['auto-start'] = true; $importJob->configuration = $config; $importJob->save(); return redirect(route('import.file.configure', [$importJob->key])); } }