parseExtensions($request->query('extensions')); $pageType = $request->query('page_type'); $pageType = is_string($pageType) && $pageType !== '' ? $pageType : null; $candidates = $this->candidateService->collect( $extensions, $pageType, app()->getLocale(), ); return $this->success( 'common.success', array_merge(['identifier' => $identifier], $candidates), ); } /** * extensions query 파라미터를 `[{type,id}]` 배열로 파싱합니다. * * JSON 문자열 또는 배열 모두 허용(잘못된 형태는 빈 배열로 폴백 — 가드는 라우트 미들웨어). * * @param mixed $raw query('extensions') * @return array */ private function parseExtensions(mixed $raw): array { if (is_string($raw)) { $decoded = json_decode($raw, true); $raw = is_array($decoded) ? $decoded : []; } if (! is_array($raw)) { return []; } $out = []; foreach ($raw as $ext) { if (is_array($ext) && isset($ext['type'], $ext['id']) && is_string($ext['type']) && is_string($ext['id'])) { $out[] = ['type' => $ext['type'], 'id' => $ext['id']]; } } return $out; } }