Update deprecated Twig code.

This commit is contained in:
James Cole 2019-12-28 09:44:56 +01:00
parent 48a0eafa0c
commit 156e2e79c7
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
8 changed files with 153 additions and 186 deletions

View File

@ -58,16 +58,8 @@ use FireflyIII\Support\Form\RuleForm;
use FireflyIII\Support\Navigation; use FireflyIII\Support\Navigation;
use FireflyIII\Support\Preferences; use FireflyIII\Support\Preferences;
use FireflyIII\Support\Steam; use FireflyIII\Support\Steam;
use FireflyIII\Support\Twig\AmountFormat;
use FireflyIII\Support\Twig\General;
use FireflyIII\Support\Twig\Rule;
use FireflyIII\Support\Twig\TransactionGroupTwig;
use FireflyIII\Support\Twig\Translation;
use FireflyIII\Validation\FireflyValidator; use FireflyIII\Validation\FireflyValidator;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
use Twig;
use Twig\Extension\DebugExtension;
use TwigBridge\Extension\Loader\Functions;
use Validator; use Validator;
/** /**
@ -85,19 +77,10 @@ class FireflyServiceProvider extends ServiceProvider
public function boot(): void public function boot(): void
{ {
Validator::resolver( Validator::resolver(
static function ($translator, $data, $rules, $messages) {
function ($translator, $data, $rules, $messages) {
return new FireflyValidator($translator, $data, $rules, $messages); return new FireflyValidator($translator, $data, $rules, $messages);
} }
); );
//$config = app('config');
//Twig::addExtension(new Functions($config));
Twig::addExtension(new General);
Twig::addExtension(new TransactionGroupTwig);
Twig::addExtension(new Translation);
Twig::addExtension(new Rule);
Twig::addExtension(new AmountFormat);
//Twig::addExtension(new DebugExtension);
} }
/** /**

View File

@ -25,15 +25,14 @@ namespace FireflyIII\Support\Twig;
use FireflyIII\Models\Account as AccountModel; use FireflyIII\Models\Account as AccountModel;
use FireflyIII\Models\TransactionCurrency; use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Log; use Twig\TwigFunction;
use Twig_Extension; use Twig\TwigFilter;
use Twig_SimpleFilter; use Twig\Extension\AbstractExtension;
use Twig_SimpleFunction;
/** /**
* Contains all amount formatting routines. * Contains all amount formatting routines.
*/ */
class AmountFormat extends Twig_Extension class AmountFormat extends AbstractExtension
{ {
/** /**
* {@inheritdoc} * {@inheritdoc}
@ -59,13 +58,13 @@ class AmountFormat extends Twig_Extension
} }
/** /**
* @return Twig_SimpleFilter * @return TwigFilter
*/ */
protected function formatAmount(): Twig_SimpleFilter protected function formatAmount(): TwigFilter
{ {
return new Twig_SimpleFilter( return new TwigFilter(
'formatAmount', 'formatAmount',
function (string $string): string { static function (string $string): string {
$currency = app('amount')->getDefaultCurrency(); $currency = app('amount')->getDefaultCurrency();
return app('amount')->formatAnything($currency, $string, true); return app('amount')->formatAnything($currency, $string, true);
@ -77,11 +76,11 @@ class AmountFormat extends Twig_Extension
/** /**
* Will format the amount by the currency related to the given account. * Will format the amount by the currency related to the given account.
* *
* @return Twig_SimpleFunction * @return TwigFunction;
*/ */
protected function formatAmountByAccount(): Twig_SimpleFunction protected function formatAmountByAccount(): TwigFunction
{ {
return new Twig_SimpleFunction( return new TwigFunction(
'formatAmountByAccount', 'formatAmountByAccount',
static function (AccountModel $account, string $amount, bool $coloured = null): string { static function (AccountModel $account, string $amount, bool $coloured = null): string {
$coloured = $coloured ?? true; $coloured = $coloured ?? true;
@ -98,13 +97,13 @@ class AmountFormat extends Twig_Extension
/** /**
* Will format the amount by the currency related to the given account. * Will format the amount by the currency related to the given account.
* *
* @return Twig_SimpleFunction * @return TwigFunction
*/ */
protected function formatAmountByCurrency(): Twig_SimpleFunction protected function formatAmountByCurrency(): TwigFunction
{ {
return new Twig_SimpleFunction( return new TwigFunction(
'formatAmountByCurrency', 'formatAmountByCurrency',
function (TransactionCurrency $currency, string $amount, bool $coloured = null): string { static function (TransactionCurrency $currency, string $amount, bool $coloured = null): string {
$coloured = $coloured ?? true; $coloured = $coloured ?? true;
return app('amount')->formatAnything($currency, $amount, $coloured); return app('amount')->formatAnything($currency, $amount, $coloured);
@ -116,11 +115,11 @@ class AmountFormat extends Twig_Extension
/** /**
* Will format the amount by the currency related to the given account. * Will format the amount by the currency related to the given account.
* *
* @return Twig_SimpleFunction * @return TwigFunction
*/ */
protected function formatAmountBySymbol(): Twig_SimpleFunction protected function formatAmountBySymbol(): TwigFunction
{ {
return new Twig_SimpleFunction( return new TwigFunction(
'formatAmountBySymbol', 'formatAmountBySymbol',
static function (string $amount, string $symbol, int $decimalPlaces = null, bool $coloured = null): string { static function (string $amount, string $symbol, int $decimalPlaces = null, bool $coloured = null): string {
@ -137,11 +136,11 @@ class AmountFormat extends Twig_Extension
} }
/** /**
* @return Twig_SimpleFilter * @return TwigFilter
*/ */
protected function formatAmountPlain(): Twig_SimpleFilter protected function formatAmountPlain(): TwigFilter
{ {
return new Twig_SimpleFilter( return new TwigFilter(
'formatAmountPlain', 'formatAmountPlain',
static function (string $string): string { static function (string $string): string {
$currency = app('amount')->getDefaultCurrency(); $currency = app('amount')->getDefaultCurrency();

View File

@ -27,16 +27,15 @@ use FireflyIII\Models\Account;
use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface; use FireflyIII\Repositories\User\UserRepositoryInterface;
use League\CommonMark\CommonMarkConverter; use League\CommonMark\CommonMarkConverter;
use Log;
use Route; use Route;
use Twig_Extension; use Twig\Extension\AbstractExtension;
use Twig_SimpleFilter; use Twig\TwigFilter;
use Twig_SimpleFunction; use Twig\TwigFunction;
/** /**
* Class TwigSupport. * Class TwigSupport.
*/ */
class General extends Twig_Extension class General extends AbstractExtension
{ {
/** /**
* @return array * @return array
@ -71,13 +70,13 @@ class General extends Twig_Extension
* Will return "active" when a part of the route matches the argument. * Will return "active" when a part of the route matches the argument.
* ie. "accounts" will match "accounts.index". * ie. "accounts" will match "accounts.index".
* *
* @return Twig_SimpleFunction * @return TwigFunction
*/ */
protected function activeRoutePartial(): Twig_SimpleFunction protected function activeRoutePartial(): TwigFunction
{ {
return new Twig_SimpleFunction( return new TwigFunction(
'activeRoutePartial', 'activeRoutePartial',
function (): string { static function (): string {
$args = func_get_args(); $args = func_get_args();
$route = $args[0]; // name of the route. $route = $args[0]; // name of the route.
$name = Route::getCurrentRoute()->getName() ?? ''; $name = Route::getCurrentRoute()->getName() ?? '';
@ -94,11 +93,11 @@ class General extends Twig_Extension
* This function will return "active" when the current route matches the first argument (even partly) * This function will return "active" when the current route matches the first argument (even partly)
* but, the variable $what has been set and matches the second argument. * but, the variable $what has been set and matches the second argument.
* *
* @return Twig_SimpleFunction * @return TwigFunction
*/ */
protected function activeRoutePartialObjectType(): Twig_SimpleFunction protected function activeRoutePartialObjectType(): TwigFunction
{ {
return new Twig_SimpleFunction( return new TwigFunction(
'activeRoutePartialObjectType', 'activeRoutePartialObjectType',
static function ($context): string { static function ($context): string {
[, $route, $objectType] = func_get_args(); [, $route, $objectType] = func_get_args();
@ -118,13 +117,13 @@ class General extends Twig_Extension
* Will return "active" when the current route matches the given argument * Will return "active" when the current route matches the given argument
* exactly. * exactly.
* *
* @return Twig_SimpleFunction * @return TwigFunction
*/ */
protected function activeRouteStrict(): Twig_SimpleFunction protected function activeRouteStrict(): TwigFunction
{ {
return new Twig_SimpleFunction( return new TwigFunction(
'activeRouteStrict', 'activeRouteStrict',
function (): string { static function (): string {
$args = func_get_args(); $args = func_get_args();
$route = $args[0]; // name of the route. $route = $args[0]; // name of the route.
@ -140,11 +139,11 @@ class General extends Twig_Extension
/** /**
* Show account balance. Only used on the front page of Firefly III. * Show account balance. Only used on the front page of Firefly III.
* *
* @return Twig_SimpleFilter * @return TwigFilter
*/ */
protected function balance(): Twig_SimpleFilter protected function balance(): TwigFilter
{ {
return new Twig_SimpleFilter( return new TwigFilter(
'balance', 'balance',
static function (?Account $account): string { static function (?Account $account): string {
if (null === $account) { if (null === $account) {
@ -161,11 +160,11 @@ class General extends Twig_Extension
/** /**
* Formats a string as a thing by converting it to a Carbon first. * Formats a string as a thing by converting it to a Carbon first.
* *
* @return Twig_SimpleFunction * @return TwigFunction
*/ */
protected function formatDate(): Twig_SimpleFunction protected function formatDate(): TwigFunction
{ {
return new Twig_SimpleFunction( return new TwigFunction(
'formatDate', 'formatDate',
function (string $date, string $format): string { function (string $date, string $format): string {
$carbon = new Carbon($date); $carbon = new Carbon($date);
@ -178,13 +177,13 @@ class General extends Twig_Extension
/** /**
* Used to convert 1024 to 1kb etc. * Used to convert 1024 to 1kb etc.
* *
* @return Twig_SimpleFilter * @return TwigFilter
*/ */
protected function formatFilesize(): Twig_SimpleFilter protected function formatFilesize(): TwigFilter
{ {
return new Twig_SimpleFilter( return new TwigFilter(
'filesize', 'filesize',
function (int $size): string { static function (int $size): string {
// less than one GB, more than one MB // less than one GB, more than one MB
if ($size < (1024 * 1024 * 2014) && $size >= (1024 * 1024)) { if ($size < (1024 * 1024 * 2014) && $size >= (1024 * 1024)) {
return round($size / (1024 * 1024), 2) . ' MB'; return round($size / (1024 * 1024), 2) . ' MB';
@ -201,11 +200,11 @@ class General extends Twig_Extension
} }
/** /**
* @return Twig_SimpleFunction * @return TwigFunction
*/ */
protected function getMetaField(): Twig_SimpleFunction protected function getMetaField(): TwigFunction
{ {
return new Twig_SimpleFunction( return new TwigFunction(
'accountGetMetaField', 'accountGetMetaField',
static function (Account $account, string $field): string { static function (Account $account, string $field): string {
/** @var AccountRepositoryInterface $repository */ /** @var AccountRepositoryInterface $repository */
@ -223,11 +222,11 @@ class General extends Twig_Extension
/** /**
* Will return true if the user is of role X. * Will return true if the user is of role X.
* *
* @return Twig_SimpleFunction * @return TwigFunction
*/ */
protected function hasRole(): Twig_SimpleFunction protected function hasRole(): TwigFunction
{ {
return new Twig_SimpleFunction( return new TwigFunction(
'hasRole', 'hasRole',
static function (string $role): bool { static function (string $role): bool {
$repository = app(UserRepositoryInterface::class); $repository = app(UserRepositoryInterface::class);
@ -241,11 +240,11 @@ class General extends Twig_Extension
} }
/** /**
* @return Twig_SimpleFilter * @return TwigFilter
*/ */
protected function markdown(): Twig_SimpleFilter protected function markdown(): TwigFilter
{ {
return new Twig_SimpleFilter( return new TwigFilter(
'markdown', 'markdown',
static function (string $text): string { static function (string $text): string {
$converter = new CommonMarkConverter; $converter = new CommonMarkConverter;
@ -258,11 +257,11 @@ class General extends Twig_Extension
/** /**
* Show icon with attachment. * Show icon with attachment.
* *
* @return Twig_SimpleFilter * @return TwigFilter
*/ */
protected function mimeIcon(): Twig_SimpleFilter protected function mimeIcon(): TwigFilter
{ {
return new Twig_SimpleFilter( return new TwigFilter(
'mimeIcon', 'mimeIcon',
static function (string $string): string { static function (string $string): string {
switch ($string) { switch ($string) {
@ -337,11 +336,11 @@ class General extends Twig_Extension
/** /**
* Basic example thing for some views. * Basic example thing for some views.
* *
* @return Twig_SimpleFunction * @return TwigFunction
*/ */
protected function phpdate(): Twig_SimpleFunction protected function phpdate(): TwigFunction
{ {
return new Twig_SimpleFunction( return new TwigFunction(
'phpdate', 'phpdate',
static function (string $str): string { static function (string $str): string {
return date($str); return date($str);

View File

@ -23,20 +23,20 @@ declare(strict_types=1);
namespace FireflyIII\Support\Twig; namespace FireflyIII\Support\Twig;
use Config; use Config;
use Twig_Extension; use Twig\Extension\AbstractExtension;
use Twig_SimpleFunction; use Twig\TwigFunction;
/** /**
* Class Rule. * Class Rule.
*/ */
class Rule extends Twig_Extension class Rule extends AbstractExtension
{ {
/** /**
* @return Twig_SimpleFunction * @return TwigFunction
*/ */
public function allActionTriggers(): Twig_SimpleFunction public function allActionTriggers(): TwigFunction
{ {
return new Twig_SimpleFunction( return new TwigFunction(
'allRuleActions', 'allRuleActions',
static function () { static function () {
// array of valid values for actions // array of valid values for actions
@ -54,11 +54,11 @@ class Rule extends Twig_Extension
} }
/** /**
* @return Twig_SimpleFunction * @return TwigFunction
*/ */
public function allJournalTriggers(): Twig_SimpleFunction public function allJournalTriggers(): TwigFunction
{ {
return new Twig_SimpleFunction( return new TwigFunction(
'allJournalTriggers', 'allJournalTriggers',
static function () { static function () {
return [ return [
@ -70,11 +70,11 @@ class Rule extends Twig_Extension
} }
/** /**
* @return Twig_SimpleFunction * @return TwigFunction
*/ */
public function allRuleTriggers(): Twig_SimpleFunction public function allRuleTriggers(): TwigFunction
{ {
return new Twig_SimpleFunction( return new TwigFunction(
'allRuleTriggers', 'allRuleTriggers',
static function () { static function () {
$ruleTriggers = array_keys(Config::get('firefly.rule-triggers')); $ruleTriggers = array_keys(Config::get('firefly.rule-triggers'));

View File

@ -30,13 +30,13 @@ use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
use Log; use Log;
use Twig_Extension; use Twig\Extension\AbstractExtension;
use Twig_SimpleFunction; use Twig\TwigFunction;
/** /**
* Class TransactionGroupTwig * Class TransactionGroupTwig
*/ */
class TransactionGroupTwig extends Twig_Extension class TransactionGroupTwig extends AbstractExtension
{ {
/** @noinspection PhpMissingParentCallCommonInspection */ /** @noinspection PhpMissingParentCallCommonInspection */
/** /**
@ -56,11 +56,11 @@ class TransactionGroupTwig extends Twig_Extension
} }
/** /**
* @return Twig_SimpleFunction * @return TwigFunction
*/ */
public function groupAmount(): Twig_SimpleFunction public function groupAmount(): TwigFunction
{ {
return new Twig_SimpleFunction( return new TwigFunction(
'groupAmount', 'groupAmount',
static function (array $array): string { static function (array $array): string {
$sums = $array['sums']; $sums = $array['sums'];
@ -92,11 +92,11 @@ class TransactionGroupTwig extends Twig_Extension
} }
/** /**
* @return Twig_SimpleFunction * @return TwigFunction
*/ */
public function journalGetMetaDate(): Twig_SimpleFunction public function journalGetMetaDate(): TwigFunction
{ {
return new Twig_SimpleFunction( return new TwigFunction(
'journalGetMetaDate', 'journalGetMetaDate',
static function (int $journalId, string $metaField) { static function (int $journalId, string $metaField) {
if ('testing' === config('app.env')) { if ('testing' === config('app.env')) {
@ -117,11 +117,11 @@ class TransactionGroupTwig extends Twig_Extension
} }
/** /**
* @return Twig_SimpleFunction * @return TwigFunction
*/ */
public function journalGetMetaField(): Twig_SimpleFunction public function journalGetMetaField(): TwigFunction
{ {
return new Twig_SimpleFunction( return new TwigFunction(
'journalGetMetaField', 'journalGetMetaField',
static function (int $journalId, string $metaField) { static function (int $journalId, string $metaField) {
if ('testing' === config('app.env')) { if ('testing' === config('app.env')) {
@ -142,11 +142,11 @@ class TransactionGroupTwig extends Twig_Extension
} }
/** /**
* @return Twig_SimpleFunction * @return TwigFunction
*/ */
public function journalHasMeta(): Twig_SimpleFunction public function journalHasMeta(): TwigFunction
{ {
return new Twig_SimpleFunction( return new TwigFunction(
'journalHasMeta', 'journalHasMeta',
static function (int $journalId, string $metaField) { static function (int $journalId, string $metaField) {
$count = DB::table('journal_meta') $count = DB::table('journal_meta')
@ -163,11 +163,11 @@ class TransactionGroupTwig extends Twig_Extension
/** /**
* Shows the amount for a single journal array. * Shows the amount for a single journal array.
* *
* @return Twig_SimpleFunction * @return TwigFunction
*/ */
public function journalArrayAmount(): Twig_SimpleFunction public function journalArrayAmount(): TwigFunction
{ {
return new Twig_SimpleFunction( return new TwigFunction(
'journalArrayAmount', 'journalArrayAmount',
function (array $array): string { function (array $array): string {
// if is not a withdrawal, amount positive. // if is not a withdrawal, amount positive.
@ -187,11 +187,11 @@ class TransactionGroupTwig extends Twig_Extension
/** /**
* Shows the amount for a single journal object. * Shows the amount for a single journal object.
* *
* @return Twig_SimpleFunction * @return TwigFunction
*/ */
public function journalObjectAmount(): Twig_SimpleFunction public function journalObjectAmount(): TwigFunction
{ {
return new Twig_SimpleFunction( return new TwigFunction(
'journalObjectAmount', 'journalObjectAmount',
function (TransactionJournal $journal): string { function (TransactionJournal $journal): string {
// if is not a withdrawal, amount positive. // if is not a withdrawal, amount positive.
@ -283,6 +283,7 @@ class TransactionGroupTwig extends Twig_Extension
if ($type === TransactionType::OPENING_BALANCE && AccountType::INITIAL_BALANCE === $destinationType) { if ($type === TransactionType::OPENING_BALANCE && AccountType::INITIAL_BALANCE === $destinationType) {
$amount = bcmul($amount, '-1'); $amount = bcmul($amount, '-1');
} }
if ($type === TransactionType::TRANSFER) { if ($type === TransactionType::TRANSFER) {
$colored = false; $colored = false;
} }

View File

@ -22,31 +22,29 @@ declare(strict_types=1);
namespace FireflyIII\Support\Twig; namespace FireflyIII\Support\Twig;
use Twig_Extension; use Twig\Extension\AbstractExtension;
use Twig_SimpleFilter; use Twig\TwigFilter;
use Twig_SimpleFunction; use Twig\TwigFunction;
/** /**
* Class Budget. * Class Budget.
*/ */
class Translation extends Twig_Extension class Translation extends AbstractExtension
{ {
/** /**
* @return array * @return array
*/ */
public function getFilters(): array public function getFilters(): array
{ {
$filters = []; return [
new TwigFilter(
$filters[] = new Twig_SimpleFilter(
'_', '_',
function ($name) { static function ($name) {
return (string)trans(sprintf('firefly.%s', $name)); return (string)trans(sprintf('firefly.%s', $name));
}, },
['is_safe' => ['html']] ['is_safe' => ['html']]
); ),
];
return $filters;
} }
/** /**
@ -60,13 +58,13 @@ class Translation extends Twig_Extension
} }
/** /**
* @return Twig_SimpleFunction * @return TwigFunction
*/ */
public function journalLinkTranslation(): Twig_SimpleFunction public function journalLinkTranslation(): TwigFunction
{ {
return new Twig_SimpleFunction( return new TwigFunction(
'journalLinkTranslation', 'journalLinkTranslation',
function (string $direction, string $original) { static function (string $direction, string $original) {
$key = sprintf('firefly.%s_%s', $original, $direction); $key = sprintf('firefly.%s_%s', $original, $direction);
$translation = trans($key); $translation = trans($key);
if ($key === $translation) { if ($key === $translation) {

View File

@ -77,9 +77,8 @@ return [
FireflyIII\Providers\RouteServiceProvider::class, FireflyIII\Providers\RouteServiceProvider::class,
// own stuff: // own stuff:
// TwigBridge\ServiceProvider::class,
PragmaRX\Google2FALaravel\ServiceProvider::class, PragmaRX\Google2FALaravel\ServiceProvider::class,
TwigBridge\ServiceProvider::class,
/* /*
* More service providers. * More service providers.
@ -135,7 +134,6 @@ return [
'URL' => Illuminate\Support\Facades\URL::class, 'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class, 'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class, 'View' => Illuminate\Support\Facades\View::class,
'Twig' => TwigBridge\Facade\Twig::class,
'Form' => Collective\Html\FormFacade::class, 'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class, 'Html' => Collective\Html\HtmlFacade::class,
'Preferences' => \FireflyIII\Support\Facades\Preferences::class, 'Preferences' => \FireflyIII\Support\Facades\Preferences::class,
@ -149,6 +147,7 @@ return [
'PiggyBankForm' => \FireflyIII\Support\Facades\PiggyBankForm::class, 'PiggyBankForm' => \FireflyIII\Support\Facades\PiggyBankForm::class,
'RuleForm' => \FireflyIII\Support\Facades\RuleForm::class, 'RuleForm' => \FireflyIII\Support\Facades\RuleForm::class,
'Google2FA' => PragmaRX\Google2FALaravel\Facade::class, 'Google2FA' => PragmaRX\Google2FALaravel\Facade::class,
'Twig' => TwigBridge\Facade\Twig::class,
], ],

View File

@ -1,38 +1,4 @@
<?php <?php
/**
* twigbridge.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
use TwigBridge\Extension\Laravel\Auth;
use TwigBridge\Extension\Laravel\Config;
use TwigBridge\Extension\Laravel\Dump;
use TwigBridge\Extension\Laravel\Input;
use TwigBridge\Extension\Laravel\Session;
use TwigBridge\Extension\Laravel\Str;
use TwigBridge\Extension\Laravel\Translator;
use TwigBridge\Extension\Laravel\Url;
use TwigBridge\Extension\Loader\Facades;
use TwigBridge\Extension\Loader\Filters;
use TwigBridge\Extension\Loader\Functions;
use TwigBridge\Twig\Template;
/** /**
* This file is part of the TwigBridge package. * This file is part of the TwigBridge package.
@ -43,6 +9,21 @@ use TwigBridge\Twig\Template;
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use FireflyIII\Support\Twig\AmountFormat;
use FireflyIII\Support\Twig\General;
use FireflyIII\Support\Twig\Rule;
use FireflyIII\Support\Twig\TransactionGroupTwig;
use FireflyIII\Support\Twig\Translation;
use TwigBridge\Extension\Laravel\Dump;
use TwigBridge\Extension\Laravel\Input;
use TwigBridge\Extension\Laravel\Model;
use TwigBridge\Extension\Laravel\Str;
use TwigBridge\Extension\Laravel\Translator;
use TwigBridge\Extension\Laravel\Url;
use TwigBridge\Extension\Loader\Facades;
use TwigBridge\Extension\Loader\Filters;
use TwigBridge\Extension\Loader\Functions;
/** /**
* Configuration options for Twig. * Configuration options for Twig.
*/ */
@ -80,7 +61,7 @@ return [
// The base template class to use for generated templates. // The base template class to use for generated templates.
// default: TwigBridge\Twig\Template // default: TwigBridge\Twig\Template
'base_template_class' => Template::class, 'base_template_class' => 'TwigBridge\Twig\Template',
// An absolute path where to store the compiled templates, or false to disable caching. If null // An absolute path where to store the compiled templates, or false to disable caching. If null
// then the cache file path is used. // then the cache file path is used.
@ -135,20 +116,27 @@ return [
Facades::class, Facades::class,
Filters::class, Filters::class,
Functions::class, Functions::class,
\TwigBridge\Extension\Laravel\Auth::class,
Auth::class, \TwigBridge\Extension\Laravel\Config::class,
Config::class,
Dump::class, Dump::class,
Input::class, Input::class,
Session::class, \TwigBridge\Extension\Laravel\Session::class,
Str::class, Str::class,
Translator::class, Translator::class,
Url::class, Url::class,
Model::class,
// 'TwigBridge\Extension\Laravel\Gate', // 'TwigBridge\Extension\Laravel\Gate',
// 'TwigBridge\Extension\Laravel\Form', // 'TwigBridge\Extension\Laravel\Form',
// 'TwigBridge\Extension\Laravel\Html', // 'TwigBridge\Extension\Laravel\Html',
// 'TwigBridge\Extension\Laravel\Legacy\Facades', // 'TwigBridge\Extension\Laravel\Legacy\Facades',
AmountFormat::class,
General::class,
Rule::class,
TransactionGroupTwig::class,
Translation::class,
], ],
/* /*