PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 6.2.14
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v6.2.14
6.2.14 6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 3.6.65 All 196 releases
fluentform / app / Modules / MCP / Tools / IntegrationTools.php

IntegrationTools.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 6.2.14, at app/Modules/MCP/Tools/IntegrationTools.php

79 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentForm\App\Modules\MCP\Tools;
4
5 defined('ABSPATH') || exit;
6
7 use FluentForm\App\Modules\MCP\Support\FormAccess;
8 use FluentForm\App\Modules\MCP\Support\MCPHelper;
9 use FluentForm\App\Services\Integrations\FormIntegrationService;
10 use FluentForm\Framework\Support\Arr;
11
12 /**
13 * Integration tools (read).
14 *
15 * The list-integrations tool reports the integration feeds configured on one
16 * form (provider, name, enabled) so an agent can answer "where do this form's
17 * entries go?". It reuses FormIntegrationService::get(), the same source the admin
18 * integrations screen reads, and is form-scoped.
19 */
20 class IntegrationTools
21 {
22 public static function definitions()
23 {
24 return [
25 'fluentform/list-integrations' => [
26 'label' => __('List Integrations', 'fluentform'),
27 'group' => __('Integrations', 'fluentform'),
28 'description' => __('List the integration feeds configured on one form (provider, name, enabled state) — the notifications and third-party connections that fire when the form is submitted. Requires form_id.', 'fluentform'),
29 'input_schema' => [
30 'type' => 'object',
31 'properties' => [
32 'form_id' => ['type' => 'integer'],
33 ],
34 'required' => ['form_id'],
35 ],
36 'execute_callback' => [self::class, 'listIntegrations'],
37 'capability' => ['fluentform_forms_manager', 'fluentform_settings_manager', 'fluentform_dashboard_access'],
38 'annotations' => ['readonly' => true],
39 ],
40 ];
41 }
42
43 public static function listIntegrations($params = [])
44 {
45 $form = FormAccess::resolveForm($params);
46 if (is_wp_error($form)) {
47 return $form;
48 }
49 $formId = (int) $form->id;
50
51 // FormIntegrationService::get() returns ['feeds' => [...], ...]; the
52 // configured feeds live under the 'feeds' key, not at the top level.
53 $result = (new FormIntegrationService())->get($formId);
54 $feeds = (isset($result['feeds']) && is_array($result['feeds'])) ? $result['feeds'] : [];
55
56 $rows = [];
57 foreach ($feeds as $feed) {
58 if (!is_array($feed)) {
59 continue;
60 }
61 $rows[] = [
62 'id' => isset($feed['id']) ? (int) $feed['id'] : null,
63 'name' => Arr::get($feed, 'name'),
64 'provider' => Arr::get($feed, 'provider'),
65 'enabled' => !empty($feed['enabled']),
66 ];
67 }
68
69 return MCPHelper::envelope(
70 sprintf(
71 /* translators: %d: number of integration feeds */
72 _n('%d integration feed configured.', '%d integration feeds configured.', count($rows), 'fluentform'),
73 count($rows)
74 ),
75 ['form_id' => $formId, 'integrations' => $rows]
76 );
77 }
78 }
79