PartKeepr\SetupBundle\Controller\ExistingConfigParserController::parseExistingConfigAction PHP Метод

parseExistingConfigAction() публичный Метод

public parseExistingConfigAction ( Request $request ) : Symfony\Component\HttpFoundation\JsonResponse
$request Symfony\Component\HttpFoundation\Request
Результат Symfony\Component\HttpFoundation\JsonResponse
    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);
    }
ExistingConfigParserController