PluginProbe
The Innovative Form Builder – IvyForms / 1.5
The Innovative Form Builder – IvyForms v1.5
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
← All changes | backend/src/Controllers/Integration/GetAllIntegrationsController.php +51 -0 0.6.1 → 1.5 View file →
@@ -1,0 +1,51 @@
1 +<?php
2 +
3 +namespace IvyForms\Controllers\Integration;
4 +
5 +use IvyForms\Common\Exceptions\ForbiddenException;
6 +use IvyForms\Common\Sanitizer\Sanitizer;
7 +use IvyForms\Controllers\Controller;
8 +use IvyForms\Services\Integrations\IntegrationRegistry;
9 +use WP_REST_Request;
10 +use WP_REST_Response;
11 +
12 +/**
13 + * Get All Integrations Controller
14 + *
15 + * Returns all registered integrations from the registry
16 + *
17 + * @since 1.0.0
18 + */
19 +class GetAllIntegrationsController extends Controller
20 +{
21 + private IntegrationRegistry $registry;
22 +
23 + public function __construct(IntegrationRegistry $registry)
24 + {
25 + $this->registry = $registry;
26 + }
27 +
28 + /**
29 + * Handle the request
30 + *
31 + * @param WP_REST_Request<array<string, mixed>> $data
32 + * @return WP_REST_Response
33 + * @throws ForbiddenException
34 + */
35 + public function handle(WP_REST_Request $data): WP_REST_Response
36 + {
37 + // Verify the nonce
38 + Sanitizer::verifyNonce($data->get_header('X-WP-Nonce'));
39 +
40 + $plan = Sanitizer::sanitizeText($data->get_param('plan'));
41 +
42 + $integrations = $plan
43 + ? $this->registry->getByPlan($plan)
44 + : $this->registry->getAll();
45 +
46 + return new WP_REST_Response([
47 + 'success' => true,
48 + 'data' => $integrations,
49 + ], 200);
50 + }
51 +}