mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-03-01 04:49:36 +00:00
Use native request functions for request param parsing
This commit is contained in:
parent
5100469751
commit
76584c3d99
1 changed files with 3 additions and 11 deletions
|
|
@ -308,21 +308,14 @@ class ScanController extends AbstractController
|
|||
{
|
||||
$this->denyAccessUnlessGranted('@tools.label_scanner');
|
||||
|
||||
$input = trim((string) $request->request->get('input', ''));
|
||||
$mode = (string) ($request->request->get('mode') ?? '');
|
||||
$infoMode = (bool) filter_var($request->request->get('info_mode', false), FILTER_VALIDATE_BOOL);
|
||||
$input = trim($request->request->getString('input', ''));
|
||||
$modeEnum = $request->request->getEnum('mode', BarcodeSourceType::class);
|
||||
$infoMode = $request->request->getBoolean('info_mode', false);
|
||||
|
||||
if ($input === '') {
|
||||
return new JsonResponse(['ok' => false], 200);
|
||||
}
|
||||
|
||||
$modeEnum = null;
|
||||
if ($mode !== '') {
|
||||
$i = (int) $mode;
|
||||
$cases = BarcodeSourceType::cases();
|
||||
$modeEnum = $cases[$i] ?? null; // null if out of range
|
||||
}
|
||||
|
||||
try {
|
||||
$scan = $this->barcodeNormalizer->scanBarcodeContent($input, $modeEnum);
|
||||
} catch (InvalidArgumentException) {
|
||||
|
|
@ -340,7 +333,6 @@ class ScanController extends AbstractController
|
|||
$redirectUrl = $this->barcodeParser->getRedirectURL($scan);
|
||||
$targetFound = true;
|
||||
} catch (EntityNotFoundException) {
|
||||
$targetFound = false;
|
||||
}
|
||||
|
||||
// Only resolve Part for part-like targets. Storelocation scans should remain null here.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue