mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-02-08 10:29:35 +00:00
Allow to filter for languages in conrad attachments
This commit is contained in:
parent
fa04fface3
commit
6d224a4a9f
2 changed files with 22 additions and 0 deletions
|
|
@ -200,6 +200,11 @@ readonly class ConradProvider implements InfoProviderInterface
|
||||||
{
|
{
|
||||||
$files = [];
|
$files = [];
|
||||||
foreach ($productMedia['manuals'] as $manual) {
|
foreach ($productMedia['manuals'] as $manual) {
|
||||||
|
//Filter out unwanted languages
|
||||||
|
if (!empty($this->settings->attachmentLanguageFilter) && !in_array($manual['language'], $this->settings->attachmentLanguageFilter, true)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$files[] = new FileDTO($manual['fullUrl'], $manual['title'] . ' (' . $manual['language'] . ')');
|
$files[] = new FileDTO($manual['fullUrl'], $manual['title'] . ' (' . $manual['language'] . ')');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,8 @@ namespace App\Settings\InfoProviderSystem;
|
||||||
use App\Form\Type\APIKeyType;
|
use App\Form\Type\APIKeyType;
|
||||||
use App\Settings\SettingsIcon;
|
use App\Settings\SettingsIcon;
|
||||||
use Jbtronics\SettingsBundle\Metadata\EnvVarMode;
|
use Jbtronics\SettingsBundle\Metadata\EnvVarMode;
|
||||||
|
use Jbtronics\SettingsBundle\ParameterTypes\ArrayType;
|
||||||
|
use Jbtronics\SettingsBundle\ParameterTypes\StringType;
|
||||||
use Jbtronics\SettingsBundle\Settings\Settings;
|
use Jbtronics\SettingsBundle\Settings\Settings;
|
||||||
use Jbtronics\SettingsBundle\Settings\SettingsParameter;
|
use Jbtronics\SettingsBundle\Settings\SettingsParameter;
|
||||||
use Jbtronics\SettingsBundle\Settings\SettingsTrait;
|
use Jbtronics\SettingsBundle\Settings\SettingsTrait;
|
||||||
|
|
@ -55,4 +57,19 @@ class ConradSettings
|
||||||
|
|
||||||
#[SettingsParameter(label: new TM("settings.ips.reichelt.include_vat"))]
|
#[SettingsParameter(label: new TM("settings.ips.reichelt.include_vat"))]
|
||||||
public bool $includeVAT = true;
|
public bool $includeVAT = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array|string[] Only attachments in these languages will be downloaded (ISO 639-1 codes)
|
||||||
|
*/
|
||||||
|
#[Assert\Unique()]
|
||||||
|
#[Assert\All([new Assert\Language()])]
|
||||||
|
#[SettingsParameter(type: ArrayType::class,
|
||||||
|
label: new TM("settings.ips.conrad.attachment_language_filter"), options: ['type' => StringType::class],
|
||||||
|
formType: LanguageType::class,
|
||||||
|
formOptions: [
|
||||||
|
'multiple' => true,
|
||||||
|
'preferred_choices' => ['en', 'de', 'fr', 'it', 'cs', 'da', 'nl', 'hu', 'hr', 'sk', 'pl']
|
||||||
|
],
|
||||||
|
)]
|
||||||
|
public array $attachmentLanguageFilter = ['en'];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue