Moved fixer API config to settings bundle

This commit is contained in:
Jan Böhmer 2025-07-06 21:42:58 +02:00
parent c0c847c5be
commit a4f2a7a7df
5 changed files with 63 additions and 4 deletions

3
.env
View file

@ -129,9 +129,6 @@ NO_URL_REWRITE_AVAILABLE=0
# Set to 1, if Part-DB should redirect all HTTP requests to HTTPS. You dont need to configure this, if your webserver already does this.
REDIRECT_TO_HTTPS=0
# If you want to use fixer.io for currency conversion, you have to set this to your API key
FIXER_API_KEY=CHANGEME
# Override value if you want to show to show a given text on homepage.
# When this is empty the content of config/banner.md is used as banner
BANNER=""

View file

@ -6,5 +6,5 @@ florianv_swap:
providers:
european_central_bank: ~ # European Central Bank (only works for EUR base currency)
fixer: # Fixer.io (needs an API key)
access_key: "%env(FIXER_API_KEY)%"
access_key: "%env(string:default:settings:exchange_rate:fixerApiKey:INVALID)%"
#exchange_rates_api: ~

View file

@ -0,0 +1,41 @@
<?php
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 - 2025 Jan Böhmer (https://github.com/jbtronics)
*
* 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);
namespace App\Settings\MiscSettings;
use App\Settings\SettingsIcon;
use Jbtronics\SettingsBundle\Metadata\EnvVarMode;
use Jbtronics\SettingsBundle\Settings\Settings;
use Jbtronics\SettingsBundle\Settings\SettingsParameter;
use Symfony\Component\Translation\TranslatableMessage as TM;
#[Settings(name: "exchange_rate", label: new TM("settings.misc.exchange_rate"))]
#[SettingsIcon("fa-money-bill-transfer")]
class ExchangeRateSettings
{
#[SettingsParameter(label: new TM("settings.misc.exchange_rate.fixer_api_key"),
description: new TM("settings.misc.exchange_rate.fixer_api_key.help"),
envVar: "FIXER_API_KEY", envVarMode: EnvVarMode::OVERWRITE,
)]
public ?string $fixerApiKey = null;
}

View file

@ -31,4 +31,7 @@ class MiscSettings
{
#[EmbeddedSettings]
public ?KiCadEDASettings $kicadEDA = null;
#[EmbeddedSettings]
public ?ExchangeRateSettings $exchangeRate = null;
}

View file

@ -12976,5 +12976,23 @@ Please note, that you can not impersonate a disabled user. If you try you will g
<target>Set to false to include non-authorized offers in the results</target>
</segment>
</unit>
<unit id="iRDDtdU" name="settings.misc.exchange_rate">
<segment>
<source>settings.misc.exchange_rate</source>
<target>Money exchange rates</target>
</segment>
</unit>
<unit id="0REngfi" name="settings.misc.exchange_rate.fixer_api_key">
<segment>
<source>settings.misc.exchange_rate.fixer_api_key</source>
<target>Fixer.io API Key</target>
</segment>
</unit>
<unit id="COLhoWD" name="settings.misc.exchange_rate.fixer_api_key.help">
<segment>
<source>settings.misc.exchange_rate.fixer_api_key.help</source>
<target>If you need exchange rates between non-euro currencies, you can input an API key from fixer.io here.</target>
</segment>
</unit>
</file>
</xliff>