Adapt Buerklin InfoProvider to new Settings mechanism

This commit is contained in:
Marc Kreidler 2025-09-11 16:12:42 +02:00
parent 5b2fc7ef4b
commit d8492ea6f3
3 changed files with 88 additions and 3 deletions

View file

@ -41,13 +41,13 @@ knpu_oauth2_client:
type: generic
provider_class: '\League\OAuth2\Client\Provider\GenericProvider'
client_id: '%env(PROVIDER_BUERKLIN_CLIENT_ID)%'
client_secret: '%env(PROVIDER_BUERKLIN_SECRET)%'
client_id: '%env(settings:buerklin:clientId)%'
client_secret: '%env(settings:buerklin:secret)%'
redirect_route: 'oauth_client_check'
redirect_params: { name: 'ip_buerklin_oauth' }
provider_options:
urlAuthorize: 'https://www.buerklin.com/authorizationserver/oauth/token'
urlAuthorize: 'https://www.buerklin.com/authorizationserver/oauth/authorize'
urlAccessToken: 'https://www.buerklin.com/authorizationserver/oauth/token'
urlResourceOwnerDetails: ''

View file

@ -0,0 +1,82 @@
<?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\InfoProviderSystem;
use App\Form\Type\APIKeyType;
use App\Settings\SettingsIcon;
use Jbtronics\SettingsBundle\Metadata\EnvVarMode;
use Jbtronics\SettingsBundle\Settings\Settings;
use Jbtronics\SettingsBundle\Settings\SettingsTrait;
use Symfony\Component\Form\Extension\Core\Type\CountryType;
use Symfony\Component\Form\Extension\Core\Type\CurrencyType;
use Symfony\Component\Form\Extension\Core\Type\LanguageType;
use Symfony\Component\Translation\TranslatableMessage as TM;
use Jbtronics\SettingsBundle\Settings\SettingsParameter;
use Symfony\Component\Validator\Constraints as Assert;
#[Settings(label: new TM("settings.ips.buerklin"))]
#[SettingsIcon("fa-plug")]
class BuerklinSettings
{
use SettingsTrait;
#[SettingsParameter(
label: new TM("settings.ips.buerklin.client_id"),
formType: APIKeyType::class,
envVar: "PROVIDER_BUERKLIN_CLIENT_ID", envVarMode: EnvVarMode::OVERWRITE
)]
public ?string $clientId = null;
#[SettingsParameter(
label: new TM("settings.ips.buerklin.secret"),
formType: APIKeyType::class,
envVar: "PROVIDER_BUERKLIN_SECRET", envVarMode: EnvVarMode::OVERWRITE
)]
public ?string $secret = null;
#[SettingsParameter(
label: new TM("settings.ips.buerklin.username"),
formType: APIKeyType::class,
envVar: "PROVIDER_BUERKLIN_USER", envVarMode: EnvVarMode::OVERWRITE
)]
public ?string $username = null;
#[SettingsParameter(
label: new TM("settings.ips.buerklin.password"),
formType: APIKeyType::class,
envVar: "PROVIDER_BUERKLIN_PASSWORD", envVarMode: EnvVarMode::OVERWRITE
)]
public ?string $password = null;
#[SettingsParameter(label: new TM("settings.ips.buerklin.currency"), formType: CurrencyType::class,
formOptions: ["preferred_choices" => ["EUR", "USD", "CHF", "GBP"]],
envVar: "PROVIDER_BUERKLIN_CURRENCY", envVarMode: EnvVarMode::OVERWRITE)]
#[Assert\Currency()]
public string $currency = "EUR";
#[SettingsParameter(label: new TM("settings.ips.buerklin.language"), formType: LanguageType::class,
envVar: "PROVIDER_BUERKLIN_LANGUAGE", envVarMode: EnvVarMode::OVERWRITE)]
#[Assert\Language]
public string $language = "en";
}

View file

@ -62,4 +62,7 @@ class InfoProviderSettings
#[EmbeddedSettings]
public ?PollinSettings $pollin = null;
#[EmbeddedSettings]
public ?BuerklinSettings $buerklin = null;
}