confirmationService = $confirmationService; } /** * @param WP_REST_Request $data * * @return WP_REST_Response * * @throws InvalidArgumentException * @throws NotFoundException * @throws ForbiddenException */ public function handle(WP_REST_Request $data): WP_REST_Response { // Verify the nonce Sanitizer::verifyNonce($data->get_header('X-WP-Nonce')); $formId = Sanitizer::sanitizeId($data->get_param('id')); $confirmationsArr = $this->confirmationService->getConfirmationsById($formId); $confirmations = []; foreach ($confirmationsArr as $confirmation) { $confirmations[] = $confirmation->toArray(); } return new WP_REST_Response([ 'message' => BackendStrings::getCommonStrings()['ok'], 'data' => $confirmations, ], 200); } }