2018-12-08 23:39:56 -06:00
|
|
|
<?php
|
2021-02-16 23:17:48 -06:00
|
|
|
/*
|
|
|
|
* DynamicConfigKey.php
|
|
|
|
* Copyright (c) 2021 james@firefly-iii.org
|
2018-12-08 23:39:56 -06:00
|
|
|
*
|
2019-10-01 23:37:26 -05:00
|
|
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
2018-12-08 23:39:56 -06:00
|
|
|
*
|
2019-10-01 23:37:26 -05: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-08 23:39:56 -06:00
|
|
|
*
|
2019-10-01 23:37:26 -05:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
2018-12-08 23:39:56 -06:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2019-10-01 23:37:26 -05:00
|
|
|
* GNU Affero General Public License for more details.
|
2018-12-08 23:39:56 -06:00
|
|
|
*
|
2019-10-01 23:37:26 -05: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-08 23:39:56 -06:00
|
|
|
*/
|
|
|
|
|
2021-03-28 04:43:07 -05:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2018-12-08 23:39:56 -06:00
|
|
|
namespace FireflyIII\Support\Binder;
|
|
|
|
|
|
|
|
use Illuminate\Routing\Route;
|
|
|
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
|
|
|
|
|
|
|
/**
|
2021-02-16 23:17:48 -06:00
|
|
|
* Class DynamicConfigKey
|
2018-12-08 23:39:56 -06:00
|
|
|
*/
|
2021-02-16 23:17:48 -06:00
|
|
|
class DynamicConfigKey
|
2018-12-08 23:39:56 -06:00
|
|
|
{
|
2021-03-07 00:43:18 -06:00
|
|
|
|
|
|
|
public static array $accepted = [
|
|
|
|
'configuration.is_demo_site',
|
|
|
|
'configuration.permission_update_check',
|
|
|
|
'configuration.single_user_mode',
|
|
|
|
'configuration.last_update_check',
|
|
|
|
];
|
2018-12-08 23:39:56 -06:00
|
|
|
/**
|
|
|
|
* @param string $value
|
|
|
|
* @param Route $route
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
|
|
|
|
*/
|
|
|
|
public static function routeBinder(string $value, Route $route): string
|
|
|
|
{
|
2021-03-07 00:43:18 -06:00
|
|
|
if (in_array($value, self::$accepted, true)) {
|
2018-12-08 23:39:56 -06:00
|
|
|
return $value;
|
|
|
|
}
|
|
|
|
throw new NotFoundHttpException;
|
|
|
|
}
|
2021-02-16 23:17:48 -06:00
|
|
|
|
2021-03-28 04:43:07 -05:00
|
|
|
}
|