importExportService = $importExportService; } /** * Handle the import request * * @param WP_REST_Request> $data * @return WP_REST_Response * @throws ForbiddenException * @throws InvalidArgumentException */ public function handle(WP_REST_Request $data): WP_REST_Response { Sanitizer::verifyNonce($data->get_header('X-WP-Nonce')); $formsData = FormImportValidator::validateImportPayload($data->get_param('importData')); // Import forms using service $importedForms = $this->importExportService->importForms($formsData); if (empty($importedForms)) { throw new InvalidArgumentException( BackendStrings::getCommonStrings()['no_forms_imported'] ); } return new WP_REST_Response([ 'success' => true, 'data' => $importedForms, 'message' => BackendStrings::getCommonStrings()['forms_imported_successfully'] ], 200); } }