mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 23:45:10 +00:00
Remove some deprecated functions.
This commit is contained in:
@@ -61,6 +61,7 @@ use FireflyIII\Support\Steam;
|
|||||||
use FireflyIII\Support\Twig\AmountFormat;
|
use FireflyIII\Support\Twig\AmountFormat;
|
||||||
use FireflyIII\Support\Twig\General;
|
use FireflyIII\Support\Twig\General;
|
||||||
use FireflyIII\Support\Twig\Journal;
|
use FireflyIII\Support\Twig\Journal;
|
||||||
|
use FireflyIII\Support\Twig\Loader\AccountLoader;
|
||||||
use FireflyIII\Support\Twig\Loader\TransactionJournalLoader;
|
use FireflyIII\Support\Twig\Loader\TransactionJournalLoader;
|
||||||
use FireflyIII\Support\Twig\Loader\TransactionLoader;
|
use FireflyIII\Support\Twig\Loader\TransactionLoader;
|
||||||
use FireflyIII\Support\Twig\PiggyBank;
|
use FireflyIII\Support\Twig\PiggyBank;
|
||||||
@@ -93,6 +94,7 @@ class FireflyServiceProvider extends ServiceProvider
|
|||||||
$config = app('config');
|
$config = app('config');
|
||||||
Twig::addExtension(new Functions($config));
|
Twig::addExtension(new Functions($config));
|
||||||
Twig::addRuntimeLoader(new TransactionLoader);
|
Twig::addRuntimeLoader(new TransactionLoader);
|
||||||
|
Twig::addRuntimeLoader(new AccountLoader);
|
||||||
Twig::addRuntimeLoader(new TransactionJournalLoader);
|
Twig::addRuntimeLoader(new TransactionJournalLoader);
|
||||||
Twig::addExtension(new PiggyBank);
|
Twig::addExtension(new PiggyBank);
|
||||||
Twig::addExtension(new General);
|
Twig::addExtension(new General);
|
||||||
|
51
app/Support/Twig/Extension/Account.php
Normal file
51
app/Support/Twig/Extension/Account.php
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Account.php
|
||||||
|
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||||
|
*
|
||||||
|
* This file is part of Firefly III.
|
||||||
|
*
|
||||||
|
* Firefly III is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Firefly III is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace FireflyIII\Support\Twig\Extension;
|
||||||
|
|
||||||
|
use FireflyIII\Models\Account as AccountModel;
|
||||||
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
|
use Twig_Extension;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Account.
|
||||||
|
*/
|
||||||
|
class Account extends Twig_Extension
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param AccountModel $account
|
||||||
|
* @param string $field
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getMetaField(AccountModel $account, string $field): string
|
||||||
|
{
|
||||||
|
/** @var AccountRepositoryInterface $repository */
|
||||||
|
$repository = app(AccountRepositoryInterface::class);
|
||||||
|
$result = $repository->getMetaValue($account, $field);
|
||||||
|
if (null === $result) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
}
|
@@ -29,6 +29,7 @@ use Route;
|
|||||||
use Twig_Extension;
|
use Twig_Extension;
|
||||||
use Twig_SimpleFilter;
|
use Twig_SimpleFilter;
|
||||||
use Twig_SimpleFunction;
|
use Twig_SimpleFunction;
|
||||||
|
use FireflyIII\Support\Twig\Extension\Account as AccountExtension;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class TwigSupport.
|
* Class TwigSupport.
|
||||||
@@ -58,12 +59,11 @@ class General extends Twig_Extension
|
|||||||
$this->getCurrencySymbol(),
|
$this->getCurrencySymbol(),
|
||||||
$this->phpdate(),
|
$this->phpdate(),
|
||||||
$this->env(),
|
$this->env(),
|
||||||
//$this->getAmountFromJournal(),
|
|
||||||
$this->activeRouteStrict(),
|
$this->activeRouteStrict(),
|
||||||
//$this->steamPositive(),
|
|
||||||
$this->activeRoutePartial(),
|
$this->activeRoutePartial(),
|
||||||
$this->activeRoutePartialWhat(),
|
$this->activeRoutePartialWhat(),
|
||||||
$this->formatDate(),
|
$this->formatDate(),
|
||||||
|
new Twig_SimpleFunction('accountGetMetaField', [AccountExtension::class, 'getMetaField']),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
52
app/Support/Twig/Loader/AccountLoader.php
Normal file
52
app/Support/Twig/Loader/AccountLoader.php
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* AccountLoader.php
|
||||||
|
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||||
|
*
|
||||||
|
* This file is part of Firefly III.
|
||||||
|
*
|
||||||
|
* Firefly III is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Firefly III is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace FireflyIII\Support\Twig\Loader;
|
||||||
|
|
||||||
|
use FireflyIII\Support\Twig\Extension\Account;
|
||||||
|
use Twig_RuntimeLoaderInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class AccountLoader.
|
||||||
|
*/
|
||||||
|
class AccountLoader implements Twig_RuntimeLoaderInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Creates the runtime implementation of a Twig element (filter/function/test).
|
||||||
|
*
|
||||||
|
* @param string $class A runtime class
|
||||||
|
*
|
||||||
|
* @return object|null The runtime instance or null if the loader does not know how to create the runtime for this class
|
||||||
|
*/
|
||||||
|
public function load($class)
|
||||||
|
{
|
||||||
|
// implement the logic to create an instance of $class
|
||||||
|
// and inject its dependencies
|
||||||
|
// most of the time, it means using your dependency injection container
|
||||||
|
|
||||||
|
if (Account::class === $class) {
|
||||||
|
return app(Account::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@@ -40,7 +40,7 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</td>
|
</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<td class="hidden-sm hidden-xs">{{ account.iban }}{% if account.iban == '' %}{{ account.getMeta('accountNumber') }}{% endif %}</td>
|
<td class="hidden-sm hidden-xs">{{ account.iban }}{% if account.iban == '' %}{{ accountGetMetaField(account, 'accountNumber') }}{% endif %}</td>
|
||||||
<td data-value="{{ account.endBalance }}" style="text-align: right;">
|
<td data-value="{{ account.endBalance }}" style="text-align: right;">
|
||||||
<span style="margin-right:5px;">
|
<span style="margin-right:5px;">
|
||||||
{{ formatAmountByAccount(account, account.endBalance) }}
|
{{ formatAmountByAccount(account, account.endBalance) }}
|
||||||
|
@@ -41,8 +41,8 @@
|
|||||||
{% for account in accounts %}
|
{% for account in accounts %}
|
||||||
<option
|
<option
|
||||||
value="{{ account.id }}"
|
value="{{ account.id }}"
|
||||||
label="{{ account.name }}{% if account.getMeta('accountRole') == 'sharedAsset' %} ({{ 'shared'|_|lower }}){% endif %}">
|
label="{{ account.name }}{% if accountGetMetaField(account, 'accountRole') == 'sharedAsset' %} ({{ 'shared'|_|lower }}){% endif %}">
|
||||||
{{ account.name }}{% if account.getMeta('accountRole') == 'sharedAsset' %} ({{ 'shared'|_|lower }}){% endif %}
|
{{ account.name }}{% if accountGetMetaField(account, 'accountRole') == 'sharedAsset' %} ({{ 'shared'|_|lower }}){% endif %}
|
||||||
</option>
|
</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
|
Reference in New Issue
Block a user