mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-01-16 07:09:33 +00:00
fix: make function never crash
This commit is contained in:
parent
0936f43326
commit
2a21a70388
1 changed files with 3 additions and 3 deletions
|
|
@ -311,15 +311,15 @@ class DigikeyProvider implements InfoProviderInterface
|
||||||
'auth_bearer' => $this->authTokenManager->getAlwaysValidTokenString(self::OAUTH_APP_NAME)
|
'auth_bearer' => $this->authTokenManager->getAlwaysValidTokenString(self::OAUTH_APP_NAME)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($response->getStatusCode() === 404) {
|
// Return empty arrays if the response has no content or fails (e.g., 404, 500+)
|
||||||
|
$media_array = $response->toArray(false);
|
||||||
|
if (empty($media_array) || !isset($media_array['MediaLinks'])) {
|
||||||
return [
|
return [
|
||||||
'datasheets' => [],
|
'datasheets' => [],
|
||||||
'images' => [],
|
'images' => [],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$media_array = $response->toArray();
|
|
||||||
|
|
||||||
foreach ($media_array['MediaLinks'] as $media_link) {
|
foreach ($media_array['MediaLinks'] as $media_link) {
|
||||||
$file = new FileDTO(url: $media_link['Url'], name: $media_link['Title']);
|
$file = new FileDTO(url: $media_link['Url'], name: $media_link['Title']);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue