PluginProbe
The Innovative Form Builder – IvyForms / 1.5.1
The Innovative Form Builder – IvyForms v1.5.1
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 / Services / Integrations / IntegrationService.php

IntegrationService.php in The Innovative Form Builder – IvyForms 1.5.1, at backend/src/Services/Integrations/IntegrationService.php

280 lines 9.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace IvyForms\Services\Integrations;
4
5 use IvyForms\Common\Exceptions\InvalidArgumentException;
6 use IvyForms\Services\GoogleSheets\Hooks\InitializationHook as GoogleSheetsInitializationHook;
7 use IvyForms\Services\Payment\PaymentsFeature;
8
9 /**
10 * Integration Service
11 *
12 * Initializes the integration registry and registers default Lite integrations
13 *
14 * @since 1.0.0
15 */
16 class IntegrationService
17 {
18 private IntegrationRegistry $registry;
19 private GoogleSheetsInitializationHook $googleSheetsInitializationHook;
20
21 public function __construct(
22 IntegrationRegistry $registry,
23 GoogleSheetsInitializationHook $googleSheetsInitializationHook
24 ) {
25 $this->registry = $registry;
26 $this->googleSheetsInitializationHook = $googleSheetsInitializationHook;
27 }
28
29 /**
30 * Initialize integrations
31 *
32 * @return void
33 * @throws InvalidArgumentException
34 */
35 public function init(): void
36 {
37 // Register Lite integrations
38 $this->registerLiteIntegrations();
39
40 /**
41 * Allow Pro/addons to register their integrations
42 *
43 * @since 1.0.0
44 *
45 * @param IntegrationRegistry $registry The integration registry instance
46 */
47 do_action('ivyforms/integrations/register', $this->registry);
48
49 $this->initializeGoogleSheets();
50 }
51
52 private function initializeGoogleSheets(): void
53 {
54 $this->googleSheetsInitializationHook->initialize();
55 }
56
57 /**
58 * Register default Lite integrations
59 *
60 * @return void
61 * @throws InvalidArgumentException
62 */
63 private function registerLiteIntegrations(): void
64 {
65 // wpDataTables Integration (Lite)
66 $this->registry->register('wpdatatables', [
67 'label' => 'wpdatatables_label',
68 'component' => 'WpDataTablesIntegrationSettings',
69 'icon' => 'wpdatatables',
70 'description' => 'wpdatatables_description',
71 'category' => 'Data Management',
72 'requiresAuth' => false,
73 'plan' => 'lite',
74 'settingsSchema' => [
75 'enabled' => [
76 'type' => 'boolean',
77 'default' => false,
78 ],
79 ],
80 ]);
81
82 // Amelia Booking Integration (Lite)
83 $this->registry->register('ameliabooking', [
84 'label' => 'ameliabooking_label',
85 'component' => 'AmeliaBookingIntegrationSettings',
86 'icon' => 'ameliabooking',
87 'description' => 'ameliabooking_description',
88 'category' => 'Booking',
89 'requiresAuth' => false,
90 'hasFormSettings' => false,
91 'plan' => 'lite',
92 'settingsSchema' => [
93 'enabled' => [
94 'type' => 'boolean',
95 'default' => false,
96 ],
97 ],
98 ]);
99
100 $this->registerPageBuilderIntegrations();
101
102 // Register Pro integrations as placeholders
103 // These will be shown with "Upgrade" button when Pro is not installed
104 // When Pro is installed, these will be overwritten by Pro's registrar
105
106 // MailChimp Integration (Pro - Essentials)
107 $this->registry->register('mailchimp', [
108 'label' => 'mailchimp_label',
109 'component' => 'MailChimpIntegrationSettings',
110 'icon' => 'mailchimp',
111 'description' => 'mailchimp_description',
112 'category' => 'Email Marketing',
113 'requiresAuth' => true,
114 'hasGlobalSettings' => true,
115 'plan' => 'essentials',
116 ]);
117
118 // Webhooks Integration (Pro - Growth)
119 $this->registry->register('webhooks', [
120 'label' => 'webhooks_label',
121 'component' => 'WebhooksIntegrationSettings',
122 'icon' => 'webhooks',
123 'description' => 'webhooks_description',
124 'category' => 'Developer Tools',
125 'requiresAuth' => false,
126 'hasGlobalSettings' => false,
127 'plan' => 'growth',
128 'learnMoreUrl' => 'https://ivyforms.com/documentation/webhooks-integration/',
129 'settingsSchema' => [
130 'enabled' => [
131 'type' => 'boolean',
132 'default' => false,
133 ],
134 ],
135 ]);
136
137 // Zapier Integration (Pro - Growth)
138 $this->registry->register('zapier', [
139 'label' => 'zapier_label',
140 'component' => 'ZapierIntegrationSettings',
141 'icon' => 'zapier',
142 'description' => 'zapier_description',
143 'category' => 'Automation',
144 'requiresAuth' => false,
145 'hasGlobalSettings' => true,
146 'plan' => 'growth',
147 ]);
148
149 // Public API Integration (Pro - Agency)
150 $this->registry->register('public-api', [
151 'label' => 'public_api_integration_label',
152 'component' => 'PublicApiSettings',
153 'icon' => 'public-api',
154 'description' => 'public_api_integration_description',
155 'category' => 'Developer Tools',
156 'requiresAuth' => false,
157 'hasGlobalSettings' => true,
158 'hasFormSettings' => false,
159 'plan' => 'agency',
160 'learnMoreUrl' => 'https://ivyforms.com/documentation/public-rest-api/',
161 'settingsSchema' => [
162 'enabled' => [
163 'type' => 'boolean',
164 'default' => false,
165 ],
166 ],
167 ]);
168
169 $this->registerPaymentIntegrations();
170
171 // Salesforce Integration (Pro - Agency)
172 // $this->registry->register('salesforce', [
173 // 'label' => 'salesforce_label',
174 // 'component' => 'SalesforceIntegrationSettings',
175 // 'icon' => 'salesforce',
176 // 'description' => 'salesforce_description',
177 // 'category' => 'CRM',
178 // 'requiresAuth' => true,
179 // 'plan' => 'agency',
180 // ]);
181
182 // Google Sheets Integration (Lite) — registered last so it appears last in UI lists
183 $this->registry->register('google_sheets', [
184 'label' => 'google_sheets_label',
185 'component' => 'GoogleSheetsIntegrationSettings',
186 'icon' => 'google_sheets',
187 'description' => 'google_sheets_description',
188 'category' => 'Data Management',
189 'requiresAuth' => true,
190 'hasGlobalSettings' => true,
191 'plan' => 'lite',
192 'learnMoreUrl' => 'https://ivyforms.com/documentation/integrations/google-sheets/',
193 'settingsSchema' => [
194 'enabled' => [
195 'type' => 'boolean',
196 'default' => false,
197 ],
198 ],
199 ]);
200 }
201
202 /**
203 * Register page builder integrations (Lite)
204 *
205 * These are informational cards only: forms are embedded through the builder itself,
206 * so there is nothing to enable or configure — the card just links to the documentation.
207 *
208 * @return void
209 * @throws InvalidArgumentException
210 */
211 private function registerPageBuilderIntegrations(): void
212 {
213 $pageBuilderSlugs = ['elementor', 'divi', 'gutenberg'];
214
215 foreach ($pageBuilderSlugs as $slug) {
216 $this->registry->register($slug, [
217 'label' => $slug . '_label',
218 'icon' => $slug,
219 'description' => $slug . '_description',
220 'category' => 'Page Builders',
221 'plan' => 'lite',
222 'docsOnly' => true,
223 'hasGlobalSettings' => false,
224 'hasFormSettings' => false,
225 'learnMoreUrl' => 'https://ivyforms.com/documentation/',
226 ]);
227 }
228 }
229
230 /**
231 * Payment integrations.
232 *
233 * Square stays "Coming soon". Stripe and PayPal follow PaymentsFeature and match
234 * the IvyForms 1.5 / Pro 1.2 release when that flag is on.
235 */
236 private function registerPaymentIntegrations(): void
237 {
238 $cardPaymentsComingSoon = !PaymentsFeature::isEnabled();
239
240 $this->registry->register('square', [
241 'label' => 'square_label',
242 'component' => 'SquareIntegrationSettings',
243 'icon' => 'square',
244 'description' => 'square_description',
245 'category' => 'Payment',
246 'requiresAuth' => true,
247 'hasGlobalSettings' => true,
248 'plan' => 'lite',
249 'learnMoreUrl' => 'https://ivyforms.com/documentation/',
250 'comingSoon' => true,
251 ]);
252
253 $this->registry->register('stripe', [
254 'label' => 'stripe_label',
255 'component' => 'StripeIntegrationSettings',
256 'icon' => 'stripe',
257 'description' => 'stripe_description',
258 'category' => 'Payment',
259 'requiresAuth' => true,
260 'hasGlobalSettings' => true,
261 'plan' => 'essentials',
262 'learnMoreUrl' => 'https://ivyforms.com/documentation/',
263 'comingSoon' => $cardPaymentsComingSoon,
264 ]);
265
266 $this->registry->register('paypal', [
267 'label' => 'paypal_label',
268 'component' => 'PaypalIntegrationSettings',
269 'icon' => 'paypal',
270 'description' => 'paypal_description',
271 'category' => 'Payment',
272 'requiresAuth' => true,
273 'hasGlobalSettings' => true,
274 'plan' => 'essentials',
275 'learnMoreUrl' => 'https://ivyforms.com/documentation/',
276 'comingSoon' => $cardPaymentsComingSoon,
277 ]);
278 }
279 }
280