← All changes
|
backend/src/Services/Integrations/IntegrationService.php
+184
-11
0.7
→
1.5.1
View file →
| @@ -2,8 +2,10 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace IvyForms\Services\Integrations; |
| 4 | 4 | |
| 5 | 5 | use IvyForms\Common\Exceptions\InvalidArgumentException; |
| 6 | +use IvyForms\Services\GoogleSheets\Hooks\InitializationHook as GoogleSheetsInitializationHook; | |
| 7 | +use IvyForms\Services\Payment\PaymentsFeature; | |
| 6 | 8 | |
| 7 | 9 | /** |
| 8 | 10 | * Integration Service |
| 9 | 11 | * |
| @@ -13,12 +15,16 @@ | ||
| 13 | 15 | */ |
| 14 | 16 | class IntegrationService |
| 15 | 17 | { |
| 16 | 18 | private IntegrationRegistry $registry; |
| 19 | + private GoogleSheetsInitializationHook $googleSheetsInitializationHook; | |
| 17 | 20 | |
| 18 | - public function __construct(IntegrationRegistry $registry) | |
| 19 | - { | |
| 21 | + public function __construct( | |
| 22 | + IntegrationRegistry $registry, | |
| 23 | + GoogleSheetsInitializationHook $googleSheetsInitializationHook | |
| 24 | + ) { | |
| 20 | 25 | $this->registry = $registry; |
| 26 | + $this->googleSheetsInitializationHook = $googleSheetsInitializationHook; | |
| 21 | 27 | } |
| 22 | 28 | |
| 23 | 29 | /** |
| 24 | 30 | * Initialize integrations |
| @@ -38,10 +44,17 @@ | ||
| 38 | 44 | * |
| 39 | 45 | * @param IntegrationRegistry $registry The integration registry instance |
| 40 | 46 | */ |
| 41 | 47 | do_action('ivyforms/integrations/register', $this->registry); |
| 48 | + | |
| 49 | + $this->initializeGoogleSheets(); | |
| 42 | 50 | } |
| 43 | 51 | |
| 52 | + private function initializeGoogleSheets(): void | |
| 53 | + { | |
| 54 | + $this->googleSheetsInitializationHook->initialize(); | |
| 55 | + } | |
| 56 | + | |
| 44 | 57 | /** |
| 45 | 58 | * Register default Lite integrations |
| 46 | 59 | * |
| 47 | 60 | * @return void |
| @@ -65,8 +78,28 @@ | ||
| 65 | 78 | ], |
| 66 | 79 | ], |
| 67 | 80 | ]); |
| 68 | 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 | + | |
| 69 | 102 | // Register Pro integrations as placeholders |
| 70 | 103 | // These will be shown with "Upgrade" button when Pro is not installed |
| 71 | 104 | // When Pro is installed, these will be overwritten by Pro's registrar |
| 72 | 105 | |
| @@ -77,22 +110,65 @@ | ||
| 77 | 110 | 'icon' => 'mailchimp', |
| 78 | 111 | 'description' => 'mailchimp_description', |
| 79 | 112 | 'category' => 'Email Marketing', |
| 80 | 113 | 'requiresAuth' => true, |
| 114 | + 'hasGlobalSettings' => true, | |
| 81 | 115 | 'plan' => 'essentials', |
| 82 | 116 | ]); |
| 83 | 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 | + | |
| 84 | 137 | // Zapier Integration (Pro - Growth) |
| 85 | -// $this->registry->register('zapier', [ | |
| 86 | -// 'label' => 'zapier_label', | |
| 87 | -// 'component' => 'ZapierIntegrationSettings', | |
| 88 | -// 'icon' => 'zapier', | |
| 89 | -// 'description' => 'zapier_description', | |
| 90 | -// 'category' => 'Automation', | |
| 91 | -// 'requiresAuth' => false, | |
| 92 | -// 'plan' => 'growth', | |
| 93 | -// ]); | |
| 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 | + ]); | |
| 94 | 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 | + | |
| 95 | 171 | // Salesforce Integration (Pro - Agency) |
| 96 | 172 | // $this->registry->register('salesforce', [ |
| 97 | 173 | // 'label' => 'salesforce_label', |
| 98 | 174 | // 'component' => 'SalesforceIntegrationSettings', |
| @@ -101,6 +177,103 @@ | ||
| 101 | 177 | // 'category' => 'CRM', |
| 102 | 178 | // 'requiresAuth' => true, |
| 103 | 179 | // 'plan' => 'agency', |
| 104 | 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 | + ]); | |
| 105 | 278 | } |
| 106 | 279 | } |