Added mechanism to parse inch and metric footprints from PR #1447

This commit is contained in:
Jan Böhmer 2026-08-02 21:25:13 +02:00
parent 642012f6c5
commit c741fb02d2
3 changed files with 28 additions and 5 deletions

View file

@ -252,12 +252,22 @@ class TMEProvider implements InfoProviderInterface, URLHandlerInfoProviderInterf
$result = [];
$footprint_name = null;
$footprint = null;
$footprint_imperial = null;
$footprint_metric = null;
foreach ($element['elements'] as $parameter) {
//Check if the parameter is the case/footprint
if ($parameter['id'] === 35) {
$footprint_name = $parameter['values'][0]['value'];
$id = $parameter['id'];
$value = $parameter['values'][0]['value'] ?? null;
// Check if the parameter is the case/footprint
// id 35 is Case, id 2932 is Case-inch, id 2931 is Case-mm
if ($id === 35) {
$footprint = $value;
} else if ($id === 2932) {
$footprint_imperial = $value;
} else if ($id === 2931) {
$footprint_metric = $value;
}
//Skip related items parameter
@ -274,10 +284,14 @@ class TMEProvider implements InfoProviderInterface, URLHandlerInfoProviderInterf
);
} else if (count($parameter['values']) === 1) {
$result[] = ParameterDTO::parseValueIncludingUnit($parameter['name'], $parameter['values'][0]['value']);
}
}
//Assign the footprint name based on the user preference and available values
$footprint_name = $this->settings->preferMetricFootprint ?
($footprint_metric ?? $footprint ?? $footprint_imperial) :
($footprint_imperial ?? $footprint ?? $footprint_metric);
return $result;
}

View file

@ -68,4 +68,7 @@ class TMESettings
envVar: "PROVIDER_TME_COUNTRY", envVarMode: EnvVarMode::OVERWRITE)]
#[Assert\Country]
public string $country = "DE";
#[SettingsParameter(label: new TM("settings.ips.tme.preferMetricFootprint"))]
public bool $preferMetricFootprint = false;
}

View file

@ -13877,5 +13877,11 @@ Buerklin-API Authentication server:
<target>Using this info provider can cause additional costs, or has very strict rate limits.</target>
</segment>
</unit>
<unit id="XMqiyE0" name="settings.ips.tme.preferMetricFootprint">
<segment>
<source>settings.ips.tme.preferMetricFootprint</source>
<target>Prefer metric footprint when both metric and imperial are available</target>
</segment>
</unit>
</file>
</xliff>