mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-21 03:42:54 +00:00
Lots of import related code.
This commit is contained in:
48
app/Import/Converter/AssetAccountIban.php
Normal file
48
app/Import/Converter/AssetAccountIban.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* AssetAccountIban.php
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace FireflyIII\Import\Converter;
|
||||
|
||||
use FireflyIII\Crud\Account\AccountCrudInterface;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class AssetAccountIban
|
||||
*
|
||||
* @package FireflyIII\Import\Converter
|
||||
*/
|
||||
class AssetAccountIban extends BasicConverter implements ConverterInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
*
|
||||
*/
|
||||
public function convert($value)
|
||||
{
|
||||
Log::debug('Going to convert value ' . $value);
|
||||
|
||||
/** @var AccountCrudInterface $repository */
|
||||
$repository = app(AccountCrudInterface::class, [$this->user]);
|
||||
|
||||
|
||||
if (isset($this->mapping[$value])) {
|
||||
Log::debug('Found account in mapping. Should exist.',['value' => $value]);
|
||||
$account = $repository->find(intval($value));
|
||||
Log::debug('Found account ', ['id' => $account->id]);
|
||||
|
||||
}
|
||||
|
||||
Log::debug('Given map is ', $this->mapping);
|
||||
|
||||
exit;
|
||||
}
|
||||
}
|
57
app/Import/Converter/BasicConverter.php
Normal file
57
app/Import/Converter/BasicConverter.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* BasicConverter.php
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace FireflyIII\Import\Converter;
|
||||
|
||||
use FireflyIII\User;
|
||||
|
||||
|
||||
/**
|
||||
* Class BasicConverter
|
||||
*
|
||||
* @package FireflyIII\Import\Converter
|
||||
*/
|
||||
class BasicConverter
|
||||
{
|
||||
/** @var bool */
|
||||
public $doMap;
|
||||
|
||||
/** @var array */
|
||||
public $mapping = [];
|
||||
|
||||
/** @var User */
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* @param mixed $doMap
|
||||
*/
|
||||
public function setDoMap(bool $doMap)
|
||||
{
|
||||
$this->doMap = $doMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $mapping
|
||||
*
|
||||
*/
|
||||
public function setMapping(array $mapping)
|
||||
{
|
||||
$this->mapping = $mapping;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
*/
|
||||
public function setUser(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
}
|
43
app/Import/Converter/ConverterInterface.php
Normal file
43
app/Import/Converter/ConverterInterface.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* ConverterInterface.php
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace FireflyIII\Import\Converter;
|
||||
use FireflyIII\User;
|
||||
|
||||
/**
|
||||
* Interface ConverterInterface
|
||||
*
|
||||
* @package FireflyIII\Import\Converter
|
||||
*/
|
||||
interface ConverterInterface
|
||||
{
|
||||
/**
|
||||
* @param $value
|
||||
*
|
||||
*/
|
||||
public function convert($value);
|
||||
|
||||
/**
|
||||
* @param bool $doMap
|
||||
*/
|
||||
public function setDoMap(bool $doMap);
|
||||
|
||||
/**
|
||||
* @param array $mapping
|
||||
*
|
||||
*/
|
||||
public function setMapping(array $mapping);
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
*/
|
||||
public function setUser(User $user);
|
||||
}
|
31
app/Import/Converter/SomeConverter.php
Normal file
31
app/Import/Converter/SomeConverter.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* SomeConverter.php
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace FireflyIII\Import\Converter;
|
||||
|
||||
/**
|
||||
* Class SomeConverter
|
||||
*
|
||||
* @package FireflyIII\Import\Converter
|
||||
*/
|
||||
class SomeConverter extends BasicConverter implements ConverterInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
*
|
||||
*/
|
||||
public function convert($value)
|
||||
{
|
||||
// // TODO: Implement convert() method.
|
||||
// throw new NotImplementedException;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user