public function parseExistingConfigAction(Request $request)
{
if (!$this->ensureAuthKey($request)) {
return $this->getAuthKeyErrorResponse();
}
$response = ['success' => true, 'errors' => [], 'message' => 'Existing configuration imported successfully'];
try {
$response['config'] = $this->get('partkeepr.setup.config_service')->configParser();
if (count($response['config']) == 0) {
$response['config'] = $this->getLegacyConfig();
}
if (count($response['config']) == 0) {
$response['message'] = 'No configuration found';
$response['existingConfig'] = false;
} else {
$response['existingConfig'] = true;
}
} catch (\Exception $e) {
$response['success'] = false;
$response['message'] = 'Configuration parse error';
$response['errors'] = [$e->getMessage()];
}
return new JsonResponse($response);
}