mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-16 14:48:11 +00:00
Massive rewrite for import routine, part 1.
This commit is contained in:
72
app/Http/Controllers/Import/IndexController.php
Normal file
72
app/Http/Controllers/Import/IndexController.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Import;
|
||||
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class FileController.
|
||||
*/
|
||||
class IndexController extends Controller
|
||||
{
|
||||
/** @var ImportJobRepositoryInterface */
|
||||
public $repository;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('mainTitleIcon', 'fa-archive');
|
||||
app('view')->share('title', trans('firefly.import_index_title'));
|
||||
$this->repository = app(ImportJobRepositoryInterface::class);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new import job for $bank with the default (global) job configuration.
|
||||
*
|
||||
* @param string $bank
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function create(string $bank)
|
||||
{
|
||||
if (!(config(sprintf('import.enabled.%s', $bank))) === true) {
|
||||
throw new FireflyException(sprintf('Cannot import from "%s" at this time.', $bank));
|
||||
}
|
||||
|
||||
$importJob = $this->repository->create($bank);
|
||||
|
||||
// from here, always go to configure step.
|
||||
return redirect(route('import.configure', [$importJob->key]));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* General import index.
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$subTitle = trans('firefly.import_index_sub_title');
|
||||
$subTitleIcon = 'fa-home';
|
||||
$routines = config('import.enabled');
|
||||
|
||||
return view('import.index', compact('subTitle', 'subTitleIcon', 'routines'));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user