Files
firefly-iii/app/Support/Binder/EitherConfigKey.php

74 lines
2.2 KiB
PHP
Raw Normal View History

2018-12-09 06:39:56 +01:00
<?php
2021-08-10 19:31:55 +02:00
2021-02-17 06:17:48 +01:00
/*
2021-08-10 19:31:55 +02:00
* EitherConfigKey.php
2021-02-17 06:17:48 +01:00
* Copyright (c) 2021 james@firefly-iii.org
2018-12-09 06:39:56 +01:00
*
* This file is part of Firefly III (https://github.com/firefly-iii).
2018-12-09 06:39:56 +01:00
*
* 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.
2018-12-09 06:39:56 +01:00
*
* This program is distributed in the hope that it will be useful,
2018-12-09 06:39:56 +01:00
* 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.
2018-12-09 06:39:56 +01:00
*
* 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/>.
2018-12-09 06:39:56 +01:00
*/
2021-08-10 19:31:55 +02:00
declare(strict_types=1);
2018-12-09 06:39:56 +01:00
namespace FireflyIII\Support\Binder;
2018-12-09 06:39:56 +01:00
use Illuminate\Routing\Route;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
2021-03-07 07:43:18 +01:00
* Class EitherConfigKey
2018-12-09 06:39:56 +01:00
*/
2021-03-07 07:43:18 +01:00
class EitherConfigKey
2018-12-09 06:39:56 +01:00
{
public static array $static
= [
'firefly.version',
'firefly.api_version',
'firefly.default_location',
'firefly.account_to_transaction',
'firefly.allowed_opposing_types',
'firefly.accountRoles',
'firefly.valid_liabilities',
'firefly.interest_periods',
'firefly.bill_periods',
'firefly.enable_external_map',
'firefly.expected_source_types',
'firefly.credit_card_types',
2022-01-30 16:53:57 +01:00
'firefly.languages',
'app.timezone',
2022-02-07 06:19:27 +01:00
'firefly.valid_view_ranges',
2022-02-26 07:55:36 +01:00
// triggers and actions:
'firefly.rule-actions',
'firefly.context-rule-actions',
2022-03-20 17:11:33 +01:00
'search.operators'
];
2018-12-09 06:39:56 +01:00
/**
* @param string $value
* @param Route $route
*
* @return string
2021-05-24 08:57:02 +02:00
* @throws NotFoundHttpException
2018-12-09 06:39:56 +01:00
*/
public static function routeBinder(string $value, Route $route): string
{
2021-03-07 07:43:18 +01:00
if (in_array($value, self::$static, true) || in_array($value, DynamicConfigKey::$accepted, true)) {
2018-12-09 06:39:56 +01:00
return $value;
}
throw new NotFoundHttpException;
}
2021-03-28 11:43:07 +02:00
}