mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-02-28 20:39:35 +00:00
Fix duplicate loadMappingFile method causing PHP fatal error
This commit is contained in:
parent
ae7e31f0bd
commit
5d9d24d92a
1 changed files with 0 additions and 33 deletions
|
|
@ -603,37 +603,4 @@ class PopulateKicadCommand extends Command
|
||||||
'Photo' => 'Device:LED', // Photodiode/phototransistor
|
'Photo' => 'Device:LED', // Photodiode/phototransistor
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Load a custom mapping file (JSON format).
|
|
||||||
*
|
|
||||||
* Expected format:
|
|
||||||
* {
|
|
||||||
* "footprints": { "SOT-23": "Package_TO_SOT_SMD:SOT-23", ... },
|
|
||||||
* "categories": { "Resistor": "Device:R", ... }
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* @return array|null The parsed mappings, or null on error
|
|
||||||
*/
|
|
||||||
private function loadMappingFile(string $path, SymfonyStyle $io): ?array
|
|
||||||
{
|
|
||||||
if (!file_exists($path)) {
|
|
||||||
$io->error(sprintf('Mapping file not found: %s', $path));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$content = file_get_contents($path);
|
|
||||||
if ($content === false) {
|
|
||||||
$io->error(sprintf('Could not read mapping file: %s', $path));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = json_decode($content, true);
|
|
||||||
if (!is_array($data)) {
|
|
||||||
$io->error(sprintf('Invalid JSON in mapping file: %s', json_last_error_msg()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue