Update deprecated Twig code.

This commit is contained in:
James Cole
2019-12-28 09:44:56 +01:00
parent 48a0eafa0c
commit 156e2e79c7
8 changed files with 153 additions and 186 deletions

View File

@@ -1,38 +1,4 @@
<?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.
@@ -43,6 +9,21 @@ use TwigBridge\Twig\Template;
* 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.
*/
@@ -57,7 +38,7 @@ return [
| File extension for Twig view files.
|
*/
'extension' => 'twig',
'extension' => 'twig',
/*
|--------------------------------------------------------------------------
@@ -72,39 +53,39 @@ return [
// When set to true, the generated templates have a __toString() method
// that you can use to display the generated nodes.
// default: false
'debug' => env('APP_DEBUG', false),
'debug' => env('APP_DEBUG', false),
// The charset used by the templates.
// default: utf-8
'charset' => 'utf-8',
'charset' => 'utf-8',
// The base template class to use for generated templates.
// 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
// then the cache file path is used.
// default: cache file storage path
'cache' => null,
'cache' => null,
// When developing with Twig, it's useful to recompile the template
// whenever the source code changes. If you don't provide a value
// for the auto_reload option, it will be determined automatically based on the debug value.
'auto_reload' => true,
'auto_reload' => true,
// If set to false, Twig will silently ignore invalid variables
// (variables and or attributes/methods that do not exist) and
// replace them with a null value. When set to true, Twig throws an exception instead.
// default: false
'strict_variables' => false,
'strict_variables' => false,
// If set to true, auto-escaping will be enabled by default for all templates.
// default: 'html'
'autoescape' => 'html',
'autoescape' => 'html',
// A flag that indicates which optimizations to apply
// (default to -1 -- all optimizations are enabled; set it to 0 to disable)
'optimizations' => -1,
'optimizations' => -1,
],
/*
@@ -116,7 +97,7 @@ return [
| NOTE: these will be overwritten if you pass data into the view with the same key.
|
*/
'globals' => [],
'globals' => [],
],
'extensions' => [
@@ -131,24 +112,31 @@ return [
| `Twig\Extension\DebugExtension` is enabled automatically if twig.debug is TRUE.
|
*/
'enabled' => [
'enabled' => [
Facades::class,
Filters::class,
Functions::class,
Auth::class,
Config::class,
\TwigBridge\Extension\Laravel\Auth::class,
\TwigBridge\Extension\Laravel\Config::class,
Dump::class,
Input::class,
Session::class,
\TwigBridge\Extension\Laravel\Session::class,
Str::class,
Translator::class,
Url::class,
Model::class,
// 'TwigBridge\Extension\Laravel\Gate',
// 'TwigBridge\Extension\Laravel\Form',
// 'TwigBridge\Extension\Laravel\Html',
// 'TwigBridge\Extension\Laravel\Legacy\Facades',
AmountFormat::class,
General::class,
Rule::class,
TransactionGroupTwig::class,
Translation::class,
],
/*
@@ -290,7 +278,7 @@ return [
| </code>
|
*/
'filters' => [
'filters' => [
'get' => 'data_get',
],
],