formService = $formService; $this->fieldService = $fieldService; $this->notificationService = $notificationService; $this->confirmationService = $confirmationService; $this->entryService = $entryService; } /** * Delete forms by IDs * * @param WP_REST_Request $data * * @return WP_REST_Response * * @throws InvalidArgumentException * @throws ForbiddenException * @throws QueryExecutionException */ public function handle(WP_REST_Request $data): WP_REST_Response { // Verify the nonce Sanitizer::verifyNonce($data->get_header('X-WP-Nonce')); // Check if the form IDs are provided if (empty($data->get_params())) { throw new InvalidArgumentException( BackendStrings::getExceptionStrings()['invalid_request_data'] ); } $ids = Sanitizer::sanitizeIds($data->get_param('ids')); $this->entryService->getDeletionManager()->deleteEntriesByFormIds($ids); $this->confirmationService->deleteConfirmationsByFormIds($ids); $this->notificationService->deleteNotificationsByFormIds($ids); $this->fieldService->deleteFieldsByFormIds($ids); $this->formService->deleteForms($ids); return new WP_REST_Response( [ 'message' => BackendStrings::getCommonStrings()['ok'], 'data' => [], ], 200 ); } }