mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 10:33:30 +00:00
76 lines
1.8 KiB
PHP
76 lines
1.8 KiB
PHP
![]() |
<?php
|
||
|
declare(strict_types=1);
|
||
|
|
||
|
namespace FireflyIII\Support\Import\Configuration\Spectre;
|
||
|
|
||
|
|
||
|
use FireflyIII\Models\ImportJob;
|
||
|
use FireflyIII\Models\SpectreProvider;
|
||
|
use FireflyIII\Support\Import\Configuration\ConfigurationInterface;
|
||
|
|
||
|
/**
|
||
|
* Class SelectBank
|
||
|
*/
|
||
|
class SelectBank implements ConfigurationInterface
|
||
|
{
|
||
|
/** @var ImportJob */
|
||
|
private $job;
|
||
|
|
||
|
/**
|
||
|
* Get the data necessary to show the configuration screen.
|
||
|
*
|
||
|
* @return array
|
||
|
*/
|
||
|
public function getData(): array
|
||
|
{
|
||
|
$config = $this->job->configuration;
|
||
|
$selection = SpectreProvider::where('country_code', $config['country'])->where('status', 'active')->get();
|
||
|
$providers = [];
|
||
|
/** @var SpectreProvider $provider */
|
||
|
foreach ($selection as $provider) {
|
||
|
$providerId = $provider->spectre_id;
|
||
|
$name = $provider->data['name'];
|
||
|
$providers[$providerId] = $name;
|
||
|
}
|
||
|
|
||
|
return compact('providers');
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Return possible warning to user.
|
||
|
*
|
||
|
* @return string
|
||
|
*/
|
||
|
public function getWarningMessage(): string
|
||
|
{
|
||
|
return '';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @param ImportJob $job
|
||
|
*
|
||
|
* @return ConfigurationInterface
|
||
|
*/
|
||
|
public function setJob(ImportJob $job)
|
||
|
{
|
||
|
$this->job = $job;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Store the result.
|
||
|
*
|
||
|
* @param array $data
|
||
|
*
|
||
|
* @return bool
|
||
|
*/
|
||
|
public function storeConfiguration(array $data): bool
|
||
|
{
|
||
|
$config = $this->job->configuration;
|
||
|
$config['bank'] = intval($data['bank_code']) ?? 0; // default to fake country.
|
||
|
$config['selected-bank'] = true;
|
||
|
$this->job->configuration = $config;
|
||
|
$this->job->save();
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
}
|