| 
									
										
										
										
											2015-05-25 07:03:26 +02:00
										 |  |  | <?php | 
					
						
							| 
									
										
										
										
											2022-03-29 14:55:51 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* | 
					
						
							|  |  |  |  * twigbridge.php | 
					
						
							|  |  |  |  * Copyright (c) 2022 james@firefly-iii.org | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * 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/>. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-02 07:49:40 +01:00
										 |  |  | declare(strict_types=1); | 
					
						
							| 
									
										
										
										
											2022-01-02 07:37:53 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-20 19:39:53 +01:00
										 |  |  | /* | 
					
						
							| 
									
										
										
										
											2019-12-28 09:44:56 +01:00
										 |  |  |  * This file is part of the TwigBridge package. | 
					
						
							| 
									
										
										
										
											2019-10-02 06:38:00 +02:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2019-12-28 09:44:56 +01:00
										 |  |  |  * @copyright Robert Crowe <hello@vivalacrowe.com> | 
					
						
							| 
									
										
										
										
											2019-10-02 06:38:00 +02:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2019-12-28 09:44:56 +01:00
										 |  |  |  * For the full copyright and license information, please view the LICENSE | 
					
						
							|  |  |  |  * file that was distributed with this source code. | 
					
						
							| 
									
										
										
										
											2019-10-02 06:38:00 +02:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2022-03-29 15:01:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-28 09:44:56 +01:00
										 |  |  | 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; | 
					
						
							| 
									
										
										
										
											2022-01-02 07:37:53 +01:00
										 |  |  | use Illuminate\Contracts\Support\Htmlable; | 
					
						
							|  |  |  | use TwigBridge\Extension\Laravel\Auth; | 
					
						
							|  |  |  | use TwigBridge\Extension\Laravel\Config; | 
					
						
							| 
									
										
										
										
											2019-03-02 20:14:45 +01:00
										 |  |  | use TwigBridge\Extension\Laravel\Dump; | 
					
						
							| 
									
										
										
										
											2022-01-02 07:37:53 +01:00
										 |  |  | use TwigBridge\Extension\Laravel\Event; | 
					
						
							| 
									
										
										
										
											2019-03-02 20:14:45 +01:00
										 |  |  | use TwigBridge\Extension\Laravel\Input; | 
					
						
							| 
									
										
										
										
											2019-12-28 09:44:56 +01:00
										 |  |  | use TwigBridge\Extension\Laravel\Model; | 
					
						
							| 
									
										
										
										
											2022-01-02 07:37:53 +01:00
										 |  |  | use TwigBridge\Extension\Laravel\Session; | 
					
						
							| 
									
										
										
										
											2019-08-10 15:09:44 +02:00
										 |  |  | use TwigBridge\Extension\Laravel\Str; | 
					
						
							|  |  |  | use TwigBridge\Extension\Laravel\Translator; | 
					
						
							|  |  |  | use TwigBridge\Extension\Laravel\Url; | 
					
						
							|  |  |  | use TwigBridge\Extension\Loader\Facades; | 
					
						
							| 
									
										
										
										
											2018-05-11 10:08:34 +02:00
										 |  |  | use TwigBridge\Extension\Loader\Filters; | 
					
						
							|  |  |  | use TwigBridge\Extension\Loader\Functions; | 
					
						
							| 
									
										
										
										
											2022-01-02 07:37:53 +01:00
										 |  |  | use TwigBridge\Extension\Loader\Globals; | 
					
						
							| 
									
										
										
										
											2019-03-02 20:14:45 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-20 19:39:53 +01:00
										 |  |  | // Configuration options for Twig.
 | 
					
						
							| 
									
										
										
										
											2015-05-25 07:03:26 +02:00
										 |  |  | return [ | 
					
						
							| 
									
										
										
										
											2024-01-01 14:45:51 +01:00
										 |  |  |     'twig'       => [ | 
					
						
							| 
									
										
										
										
											2022-03-29 15:01:12 +02:00
										 |  |  |         'extension'    => 'twig', | 
					
						
							|  |  |  |         'environment'  => [ | 
					
						
							|  |  |  |             'debug'            => env('APP_DEBUG', false), | 
					
						
							|  |  |  |             'charset'          => 'utf-8', | 
					
						
							|  |  |  |             'cache'            => null, | 
					
						
							|  |  |  |             'auto_reload'      => true, | 
					
						
							| 
									
										
										
										
											2022-01-02 07:37:53 +01:00
										 |  |  |             'strict_variables' => false, | 
					
						
							| 
									
										
										
										
											2022-03-29 15:01:12 +02:00
										 |  |  |             'autoescape'       => 'html', | 
					
						
							|  |  |  |             'optimizations'    => -1, | 
					
						
							| 
									
										
										
										
											2022-01-02 07:37:53 +01:00
										 |  |  |         ], | 
					
						
							| 
									
										
										
										
											2015-05-25 07:03:26 +02:00
										 |  |  |         /* | 
					
						
							|  |  |  |         |-------------------------------------------------------------------------- | 
					
						
							| 
									
										
										
										
											2022-01-02 07:37:53 +01:00
										 |  |  |         | Safe Classes | 
					
						
							| 
									
										
										
										
											2015-05-25 07:03:26 +02:00
										 |  |  |         |-------------------------------------------------------------------------- | 
					
						
							|  |  |  |         | | 
					
						
							| 
									
										
										
										
											2022-01-02 07:37:53 +01:00
										 |  |  |         | When set, the output of the `__string` method of the following classes will not be escaped. | 
					
						
							|  |  |  |         | default: Laravel's Htmlable, which the HtmlString class implements. | 
					
						
							| 
									
										
										
										
											2015-05-25 07:03:26 +02:00
										 |  |  |         | | 
					
						
							|  |  |  |         */ | 
					
						
							| 
									
										
										
										
											2022-01-02 07:37:53 +01:00
										 |  |  |         'safe_classes' => [ | 
					
						
							|  |  |  |             Htmlable::class => ['html'], | 
					
						
							| 
									
										
										
										
											2015-05-25 07:03:26 +02:00
										 |  |  |         ], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         /* | 
					
						
							|  |  |  |         |-------------------------------------------------------------------------- | 
					
						
							|  |  |  |         | Global variables | 
					
						
							|  |  |  |         |-------------------------------------------------------------------------- | 
					
						
							|  |  |  |         | | 
					
						
							|  |  |  |         | These will always be passed in and can be accessed as Twig variables. | 
					
						
							|  |  |  |         | NOTE: these will be overwritten if you pass data into the view with the same key. | 
					
						
							|  |  |  |         | | 
					
						
							|  |  |  |         */ | 
					
						
							| 
									
										
										
										
											2022-03-29 15:01:12 +02:00
										 |  |  |         'globals'      => [], | 
					
						
							| 
									
										
										
										
											2015-05-25 07:03:26 +02:00
										 |  |  |     ], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     'extensions' => [ | 
					
						
							|  |  |  |         /* | 
					
						
							|  |  |  |         |-------------------------------------------------------------------------- | 
					
						
							|  |  |  |         | Extensions | 
					
						
							|  |  |  |         |-------------------------------------------------------------------------- | 
					
						
							|  |  |  |         | | 
					
						
							|  |  |  |         | Enabled extensions. | 
					
						
							|  |  |  |         | | 
					
						
							| 
									
										
										
										
											2019-03-02 20:14:45 +01:00
										 |  |  |         | `Twig\Extension\DebugExtension` is enabled automatically if twig.debug is TRUE. | 
					
						
							| 
									
										
										
										
											2015-05-25 07:03:26 +02:00
										 |  |  |         | | 
					
						
							|  |  |  |         */ | 
					
						
							| 
									
										
										
										
											2022-03-29 15:01:12 +02:00
										 |  |  |         'enabled'   => [ | 
					
						
							| 
									
										
										
										
											2018-04-02 14:43:06 +02:00
										 |  |  |             Facades::class, | 
					
						
							|  |  |  |             Filters::class, | 
					
						
							|  |  |  |             Functions::class, | 
					
						
							| 
									
										
										
										
											2022-01-02 07:37:53 +01:00
										 |  |  |             Event::class, | 
					
						
							|  |  |  |             Globals::class, | 
					
						
							|  |  |  |             Auth::class, | 
					
						
							|  |  |  |             Config::class, | 
					
						
							| 
									
										
										
										
											2018-04-02 14:43:06 +02:00
										 |  |  |             Dump::class, | 
					
						
							|  |  |  |             Input::class, | 
					
						
							| 
									
										
										
										
											2022-01-02 07:37:53 +01:00
										 |  |  |             Session::class, | 
					
						
							| 
									
										
										
										
											2018-04-02 14:43:06 +02:00
										 |  |  |             Str::class, | 
					
						
							|  |  |  |             Translator::class, | 
					
						
							|  |  |  |             Url::class, | 
					
						
							| 
									
										
										
										
											2019-12-28 09:44:56 +01:00
										 |  |  |             Model::class, | 
					
						
							| 
									
										
										
										
											2022-01-02 07:37:53 +01:00
										 |  |  |             // Firefly III
 | 
					
						
							| 
									
										
										
										
											2019-12-28 09:44:56 +01:00
										 |  |  |             AmountFormat::class, | 
					
						
							|  |  |  |             General::class, | 
					
						
							|  |  |  |             Rule::class, | 
					
						
							|  |  |  |             TransactionGroupTwig::class, | 
					
						
							|  |  |  |             Translation::class, | 
					
						
							| 
									
										
										
										
											2015-05-25 07:03:26 +02:00
										 |  |  |         ], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         /* | 
					
						
							|  |  |  |         |-------------------------------------------------------------------------- | 
					
						
							|  |  |  |         | Facades | 
					
						
							|  |  |  |         |-------------------------------------------------------------------------- | 
					
						
							|  |  |  |         | | 
					
						
							|  |  |  |         | Available facades. Access like `{{ Config.get('foo.bar') }}`. | 
					
						
							|  |  |  |         | | 
					
						
							|  |  |  |         | Each facade can take an optional array of options. To mark the whole facade | 
					
						
							|  |  |  |         | as safe you can set the option `'is_safe' => true`. Setting the facade as | 
					
						
							|  |  |  |         | safe means that any HTML returned will not be escaped. | 
					
						
							|  |  |  |         | | 
					
						
							|  |  |  |         | It is advisable to not set the whole facade as safe and instead mark the | 
					
						
							|  |  |  |         | each appropriate method as safe for security reasons. You can do that with | 
					
						
							|  |  |  |         | the following syntax: | 
					
						
							|  |  |  |         | | 
					
						
							|  |  |  |         | <code> | 
					
						
							|  |  |  |         |     'Form' => [ | 
					
						
							|  |  |  |         |         'is_safe' => [ | 
					
						
							|  |  |  |         |             'open' | 
					
						
							|  |  |  |         |         ] | 
					
						
							|  |  |  |         |     ] | 
					
						
							|  |  |  |         | </code> | 
					
						
							|  |  |  |         | | 
					
						
							|  |  |  |         | The values of the `is_safe` array must match the called method on the facade | 
					
						
							|  |  |  |         | in order to be marked as safe. | 
					
						
							|  |  |  |         | | 
					
						
							|  |  |  |         */ | 
					
						
							| 
									
										
										
										
											2022-03-29 15:01:12 +02:00
										 |  |  |         'facades'   => [ | 
					
						
							| 
									
										
										
										
											2019-08-10 16:50:37 +02:00
										 |  |  |             'Breadcrumbs'   => [ | 
					
						
							| 
									
										
										
										
											2015-05-25 07:03:26 +02:00
										 |  |  |                 'is_safe' => [ | 
					
						
							| 
									
										
										
										
											2017-12-23 20:46:52 +01:00
										 |  |  |                     'render', | 
					
						
							| 
									
										
										
										
											2016-08-26 08:21:31 +02:00
										 |  |  |                 ], | 
					
						
							| 
									
										
										
										
											2015-05-25 07:03:26 +02:00
										 |  |  |             ], | 
					
						
							|  |  |  |             'Session', | 
					
						
							|  |  |  |             'Route', | 
					
						
							|  |  |  |             'Auth', | 
					
						
							|  |  |  |             'Lang', | 
					
						
							| 
									
										
										
										
											2016-08-03 20:57:01 +02:00
										 |  |  |             'Preferences', | 
					
						
							| 
									
										
										
										
											2015-05-25 07:03:26 +02:00
										 |  |  |             'URL', | 
					
						
							| 
									
										
										
										
											2017-08-30 07:40:39 +02:00
										 |  |  |             'Steam', | 
					
						
							| 
									
										
										
										
											2015-05-25 07:03:26 +02:00
										 |  |  |             'Config', | 
					
						
							| 
									
										
										
										
											2017-07-15 22:17:24 +02:00
										 |  |  |             'Request', | 
					
						
							| 
									
										
										
										
											2023-06-04 15:16:17 +02:00
										 |  |  |             'Html', | 
					
						
							| 
									
										
										
										
											2019-08-10 16:50:37 +02:00
										 |  |  |             'ExpandedForm'  => [ | 
					
						
							| 
									
										
										
										
											2019-08-10 15:09:44 +02:00
										 |  |  |                 'is_safe' => [ | 
					
						
							| 
									
										
										
										
											2022-12-29 19:43:43 +01:00
										 |  |  |                     'date', | 
					
						
							|  |  |  |                     'text', | 
					
						
							|  |  |  |                     'select', | 
					
						
							|  |  |  |                     'balance', | 
					
						
							|  |  |  |                     'optionsList', | 
					
						
							|  |  |  |                     'checkbox', | 
					
						
							|  |  |  |                     'amount', | 
					
						
							|  |  |  |                     'tags', | 
					
						
							|  |  |  |                     'integer', | 
					
						
							|  |  |  |                     'textarea', | 
					
						
							|  |  |  |                     'location', | 
					
						
							|  |  |  |                     'file', | 
					
						
							|  |  |  |                     'staticText', | 
					
						
							|  |  |  |                     'password', | 
					
						
							| 
									
										
										
										
											2024-12-11 07:23:46 +01:00
										 |  |  |                     'passwordWithValue', | 
					
						
							| 
									
										
										
										
											2022-12-29 19:43:43 +01:00
										 |  |  |                     'nonSelectableAmount', | 
					
						
							|  |  |  |                     'number', | 
					
						
							|  |  |  |                     'amountNoCurrency', | 
					
						
							|  |  |  |                     'percentage', | 
					
						
							|  |  |  |                     'objectGroup', | 
					
						
							| 
									
										
										
										
											2019-08-10 15:09:44 +02:00
										 |  |  |                 ], | 
					
						
							|  |  |  |             ], | 
					
						
							| 
									
										
										
										
											2019-08-10 16:50:37 +02:00
										 |  |  |             'AccountForm'   => [ | 
					
						
							| 
									
										
										
										
											2019-08-10 15:09:44 +02:00
										 |  |  |                 'is_safe' => [ | 
					
						
							| 
									
										
										
										
											2022-12-29 19:43:43 +01:00
										 |  |  |                     'activeWithdrawalDestinations', | 
					
						
							|  |  |  |                     'activeDepositDestinations', | 
					
						
							|  |  |  |                     'assetAccountCheckList', | 
					
						
							|  |  |  |                     'assetAccountList', | 
					
						
							|  |  |  |                     'longAccountList', | 
					
						
							| 
									
										
										
										
											2024-12-06 08:10:31 +01:00
										 |  |  |                     'assetLiabilityMultiAccountList', | 
					
						
							| 
									
										
										
										
											2019-08-10 15:09:44 +02:00
										 |  |  |                 ], | 
					
						
							| 
									
										
										
										
											2015-05-25 07:03:26 +02:00
										 |  |  |             ], | 
					
						
							| 
									
										
										
										
											2019-08-10 16:50:37 +02:00
										 |  |  |             'CurrencyForm'  => [ | 
					
						
							|  |  |  |                 'is_safe' => [ | 
					
						
							| 
									
										
										
										
											2022-12-29 19:43:43 +01:00
										 |  |  |                     'currencyList', | 
					
						
							|  |  |  |                     'currencyListEmpty', | 
					
						
							|  |  |  |                     'balanceAll', | 
					
						
							| 
									
										
										
										
											2019-08-10 16:50:37 +02:00
										 |  |  |                 ], | 
					
						
							|  |  |  |             ], | 
					
						
							| 
									
										
										
										
											2020-03-17 16:06:30 +00:00
										 |  |  |             'PiggyBankForm' => [ | 
					
						
							|  |  |  |                 'is_safe' => [ | 
					
						
							|  |  |  |                     'piggyBankList', | 
					
						
							| 
									
										
										
										
											2019-08-10 16:50:37 +02:00
										 |  |  |                 ], | 
					
						
							| 
									
										
										
										
											2020-03-17 16:06:30 +00:00
										 |  |  |             ], | 
					
						
							| 
									
										
										
										
											2019-08-10 16:50:37 +02:00
										 |  |  |             'RuleForm'      => [ | 
					
						
							|  |  |  |                 'is_safe' => [ | 
					
						
							| 
									
										
										
										
											2022-12-29 19:43:43 +01:00
										 |  |  |                     'ruleGroupList', | 
					
						
							|  |  |  |                     'ruleGroupListWithEmpty', | 
					
						
							| 
									
										
										
										
											2019-08-10 16:50:37 +02:00
										 |  |  |                 ], | 
					
						
							|  |  |  |             ], | 
					
						
							| 
									
										
										
										
											2015-05-25 07:03:26 +02:00
										 |  |  |         ], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         /* | 
					
						
							|  |  |  |         |-------------------------------------------------------------------------- | 
					
						
							|  |  |  |         | Functions | 
					
						
							|  |  |  |         |-------------------------------------------------------------------------- | 
					
						
							|  |  |  |         | | 
					
						
							|  |  |  |         | Available functions. Access like `{{ secure_url(...) }}`. | 
					
						
							|  |  |  |         | | 
					
						
							|  |  |  |         | Each function can take an optional array of options. These options are | 
					
						
							| 
									
										
										
										
											2019-03-02 20:14:45 +01:00
										 |  |  |         | passed directly to `Twig\TwigFunction`. | 
					
						
							| 
									
										
										
										
											2015-05-25 07:03:26 +02:00
										 |  |  |         | | 
					
						
							|  |  |  |         | So for example, to mark a function as safe you can do the following: | 
					
						
							|  |  |  |         | | 
					
						
							|  |  |  |         | <code> | 
					
						
							|  |  |  |         |     'link_to' => [ | 
					
						
							|  |  |  |         |         'is_safe' => ['html'] | 
					
						
							|  |  |  |         |     ] | 
					
						
							|  |  |  |         | </code> | 
					
						
							|  |  |  |         | | 
					
						
							|  |  |  |         | The options array also takes a `callback` that allows you to name the | 
					
						
							|  |  |  |         | function differently in your Twig templates than what it's actually called. | 
					
						
							|  |  |  |         | | 
					
						
							|  |  |  |         | <code> | 
					
						
							|  |  |  |         |     'link' => [ | 
					
						
							|  |  |  |         |         'callback' => 'link_to' | 
					
						
							|  |  |  |         |     ] | 
					
						
							|  |  |  |         | </code> | 
					
						
							|  |  |  |         | | 
					
						
							|  |  |  |         */ | 
					
						
							|  |  |  |         'functions' => [ | 
					
						
							|  |  |  |             'elixir', | 
					
						
							|  |  |  |             'head', | 
					
						
							|  |  |  |             'last', | 
					
						
							| 
									
										
										
										
											2019-03-02 20:14:45 +01:00
										 |  |  |             'mix', | 
					
						
							| 
									
										
										
										
											2015-05-25 07:03:26 +02:00
										 |  |  |         ], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         /* | 
					
						
							|  |  |  |         |-------------------------------------------------------------------------- | 
					
						
							|  |  |  |         | Filters | 
					
						
							|  |  |  |         |-------------------------------------------------------------------------- | 
					
						
							|  |  |  |         | | 
					
						
							|  |  |  |         | Available filters. Access like `{{ variable|filter }}`. | 
					
						
							|  |  |  |         | | 
					
						
							|  |  |  |         | Each filter can take an optional array of options. These options are | 
					
						
							| 
									
										
										
										
											2019-03-02 20:14:45 +01:00
										 |  |  |         | passed directly to `Twig\TwigFilter`. | 
					
						
							| 
									
										
										
										
											2015-05-25 07:03:26 +02:00
										 |  |  |         | | 
					
						
							|  |  |  |         | So for example, to mark a filter as safe you can do the following: | 
					
						
							|  |  |  |         | | 
					
						
							|  |  |  |         | <code> | 
					
						
							|  |  |  |         |     'studly_case' => [ | 
					
						
							|  |  |  |         |         'is_safe' => ['html'] | 
					
						
							|  |  |  |         |     ] | 
					
						
							|  |  |  |         | </code> | 
					
						
							|  |  |  |         | | 
					
						
							|  |  |  |         | The options array also takes a `callback` that allows you to name the | 
					
						
							|  |  |  |         | filter differently in your Twig templates than what is actually called. | 
					
						
							|  |  |  |         | | 
					
						
							|  |  |  |         | <code> | 
					
						
							|  |  |  |         |     'snake' => [ | 
					
						
							|  |  |  |         |         'callback' => 'snake_case' | 
					
						
							|  |  |  |         |     ] | 
					
						
							|  |  |  |         | </code> | 
					
						
							|  |  |  |         | | 
					
						
							|  |  |  |         */ | 
					
						
							| 
									
										
										
										
											2022-03-29 15:01:12 +02:00
										 |  |  |         'filters'   => [ | 
					
						
							| 
									
										
										
										
											2016-09-16 06:19:40 +02:00
										 |  |  |             'get' => 'data_get', | 
					
						
							|  |  |  |         ], | 
					
						
							| 
									
										
										
										
											2016-08-26 08:21:31 +02:00
										 |  |  |     ], | 
					
						
							| 
									
										
										
										
											2015-05-25 22:04:24 +02:00
										 |  |  | ]; |