PluginProbe
The Innovative Form Builder – IvyForms / 0.1.2
The Innovative Form Builder – IvyForms v0.1.2
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / backend / src / Controllers / Confirmation / GetConfirmationsController.php

GetConfirmationsController.php in The Innovative Form Builder – IvyForms 0.1.2, at backend/src/Controllers/Confirmation/GetConfirmationsController.php

68 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * @copyright © TMS-Plugins. All rights.
5 * @licence See COPYING.md for license details.
6 */
7
8 namespace IvyForms\Controllers\Confirmation;
9
10 // phpcs:disable PSR1.Files.SideEffects
11 if (!defined('ABSPATH')) {
12 exit; // Exit if accessed directly
13 }
14
15 use IvyForms\Common\Exceptions\ForbiddenException;
16 use IvyForms\Common\Exceptions\InvalidArgumentException;
17 use IvyForms\Common\Exceptions\NotFoundException;
18 use IvyForms\Common\Sanitizer\Sanitizer;
19 use IvyForms\Controllers\Controller;
20 use IvyForms\Services\Confirmation\ConfirmationService;
21 use WP_REST_Request;
22 use WP_REST_Response;
23
24 /**
25 * Class GetConfirmationsController
26 *
27 * @package IvyForms\Application\Controllers\Confirmation
28 */
29 class GetConfirmationsController extends Controller
30 {
31 private ConfirmationService $confirmationService;
32
33 public function __construct(
34 ConfirmationService $confirmationService
35 ) {
36 $this->confirmationService = $confirmationService;
37 }
38
39 /**
40 * @param WP_REST_Request $data
41 *
42 * @return WP_REST_Response
43 *
44 * @throws InvalidArgumentException
45 * @throws NotFoundException
46 * @throws ForbiddenException
47 */
48 public function handle(WP_REST_Request $data): WP_REST_Response
49 {
50 // Verify the nonce
51 Sanitizer::verifyNonce($data->get_header('X-WP-Nonce'));
52 $formId = Sanitizer::sanitizeId($data->get_param('id'));
53
54 $confirmationsArr = $this->confirmationService->getConfirmationsById($formId);
55
56 $confirmations = [];
57
58 foreach ($confirmationsArr as $confirmation) {
59 $confirmations[] = $confirmation->toArray();
60 }
61
62 return new WP_REST_Response([
63 'message' => 'OK',
64 $confirmations
65 ], 200);
66 }
67 }
68