Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Remove some deprecated functions.
James Cole900e8202e690
diff --git a/app/Providers/FireflyServiceProvider.php b/app/Providers/FireflyServiceProvider.phpindex 6bea0cca5b..842103b20e 100644--- a/app/Providers/FireflyServiceProvider.php+++ b/app/Providers/FireflyServiceProvider.php@@ -61,6 +61,7 @@ use FireflyIII\Support\Steam;use FireflyIII\Support\Twig\AmountFormat;use FireflyIII\Support\Twig\General;use FireflyIII\Support\Twig\Journal;+use FireflyIII\Support\Twig\Loader\AccountLoader;use FireflyIII\Support\Twig\Loader\TransactionJournalLoader;use FireflyIII\Support\Twig\Loader\TransactionLoader;use FireflyIII\Support\Twig\PiggyBank;@@ -93,6 +94,7 @@ class FireflyServiceProvider extends ServiceProvider$config = app('config');Twig::addExtension(new Functions($config));Twig::addRuntimeLoader(new TransactionLoader);+ Twig::addRuntimeLoader(new AccountLoader);Twig::addRuntimeLoader(new TransactionJournalLoader);Twig::addExtension(new PiggyBank);Twig::addExtension(new General);diff --git a/app/Support/Twig/Extension/Account.php b/app/Support/Twig/Extension/Account.phpnew file mode 100644index 0000000000..c3e61b32ba--- /dev/null+++ b/app/Support/Twig/Extension/Account.php@@ -0,0 +1,51 @@+<?php+/**+ * Account.php+ * Copyright (c) 2018 [email protected]+ *+ * 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;+ }+}diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.phpindex eb53c2311d..ca06db2ada 100644--- a/app/Support/Twig/General.php+++ b/app/Support/Twig/General.php@@ -29,6 +29,7 @@ use Route;use Twig_Extension;use Twig_SimpleFilter;use Twig_SimpleFunction;+use FireflyIII\Support\Twig\Extension\Account as AccountExtension;/*** Class TwigSupport.@@ -58,12 +59,11 @@ class General extends Twig_Extension$this->getCurrencySymbol(),$this->phpdate(),$this->env(),- //$this->getAmountFromJournal(),$this->activeRouteStrict(),- //$this->steamPositive(),$this->activeRoutePartial(),$this->activeRoutePartialWhat(),$this->formatDate(),+ new Twig_SimpleFunction('accountGetMetaField', [AccountExtension::class, 'getMetaField']),];}diff --git a/app/Support/Twig/Loader/AccountLoader.php b/app/Support/Twig/Loader/AccountLoader.phpnew file mode 100644index 0000000000..be92e6586d--- /dev/null+++ b/app/Support/Twig/Loader/AccountLoader.php@@ -0,0 +1,52 @@+<?php+/**+ * AccountLoader.php+ * Copyright (c) 2018 [email protected]+ *+ * 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;+ }+}diff --git a/resources/views/list/accounts.twig b/resources/views/list/accounts.twigindex 90c69be280..7d016cbf77 100644--- a/resources/views/list/accounts.twig+++ b/resources/views/list/accounts.twig@@ -40,7 +40,7 @@{% endfor %}</td>{% 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;"><span style="margin-right:5px;">{{ formatAmountByAccount(account, account.endBalance) }}diff --git a/resources/views/reports/index.twig b/resources/views/reports/index.twigindex fac9b2b1b8..ea2ef75733 100644--- a/resources/views/reports/index.twig+++ b/resources/views/reports/index.twig@@ -41,8 +41,8 @@{% for account in accounts %}<optionvalue="{{ account.id }}"- label="{{ account.name }}{% if account.getMeta('accountRole') == 'sharedAsset' %} ({{ 'shared'|_|lower }}){% endif %}">- {{ account.name }}{% if account.getMeta('accountRole') == 'sharedAsset' %} ({{ 'shared'|_|lower }}){% endif %}+ label="{{ account.name }}{% if accountGetMetaField(account, 'accountRole') == 'sharedAsset' %} ({{ 'shared'|_|lower }}){% endif %}">+ {{ account.name }}{% if accountGetMetaField(account, 'accountRole') == 'sharedAsset' %} ({{ 'shared'|_|lower }}){% endif %}</option>{% endfor %}</select>