| 1 |
<?php |
| 2 |
|
| 3 |
namespace IvyForms\Services\Integrations; |
| 4 |
|
| 5 |
use IvyForms\Common\Exceptions\InvalidArgumentException; |
| 6 |
|
| 7 |
/** |
| 8 |
* Integration Service |
| 9 |
* |
| 10 |
* Initializes the integration registry and registers default Lite integrations |
| 11 |
* |
| 12 |
* @since 1.0.0 |
| 13 |
*/ |
| 14 |
class IntegrationService |
| 15 |
{ |
| 16 |
private IntegrationRegistry $registry; |
| 17 |
|
| 18 |
public function __construct(IntegrationRegistry $registry) |
| 19 |
{ |
| 20 |
$this->registry = $registry; |
| 21 |
} |
| 22 |
|
| 23 |
/** |
| 24 |
* Initialize integrations |
| 25 |
* |
| 26 |
* @return void |
| 27 |
* @throws InvalidArgumentException |
| 28 |
*/ |
| 29 |
public function init(): void |
| 30 |
{ |
| 31 |
// Register Lite integrations |
| 32 |
$this->registerLiteIntegrations(); |
| 33 |
|
| 34 |
/** |
| 35 |
* Allow Pro/addons to register their integrations |
| 36 |
* |
| 37 |
* @since 1.0.0 |
| 38 |
* |
| 39 |
* @param IntegrationRegistry $registry The integration registry instance |
| 40 |
*/ |
| 41 |
do_action('ivyforms/integrations/register', $this->registry); |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* Register default Lite integrations |
| 46 |
* |
| 47 |
* @return void |
| 48 |
* @throws InvalidArgumentException |
| 49 |
*/ |
| 50 |
private function registerLiteIntegrations(): void |
| 51 |
{ |
| 52 |
// wpDataTables Integration (Lite) |
| 53 |
$this->registry->register('wpdatatables', [ |
| 54 |
'label' => 'wpdatatables_label', |
| 55 |
'component' => 'WpDataTablesIntegrationSettings', |
| 56 |
'icon' => 'wpdatatables', |
| 57 |
'description' => 'wpdatatables_description', |
| 58 |
'category' => 'Data Management', |
| 59 |
'requiresAuth' => false, |
| 60 |
'plan' => 'lite', |
| 61 |
'settingsSchema' => [ |
| 62 |
'enabled' => [ |
| 63 |
'type' => 'boolean', |
| 64 |
'default' => false, |
| 65 |
], |
| 66 |
], |
| 67 |
]); |
| 68 |
|
| 69 |
// Register Pro integrations as placeholders |
| 70 |
// These will be shown with "Upgrade" button when Pro is not installed |
| 71 |
// When Pro is installed, these will be overwritten by Pro's registrar |
| 72 |
|
| 73 |
// MailChimp Integration (Pro - Essentials) |
| 74 |
$this->registry->register('mailchimp', [ |
| 75 |
'label' => 'mailchimp_label', |
| 76 |
'component' => 'MailChimpIntegrationSettings', |
| 77 |
'icon' => 'mailchimp', |
| 78 |
'description' => 'mailchimp_description', |
| 79 |
'category' => 'Email Marketing', |
| 80 |
'requiresAuth' => true, |
| 81 |
'plan' => 'essentials', |
| 82 |
]); |
| 83 |
|
| 84 |
// 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 |
// ]); |
| 94 |
|
| 95 |
// Salesforce Integration (Pro - Agency) |
| 96 |
// $this->registry->register('salesforce', [ |
| 97 |
// 'label' => 'salesforce_label', |
| 98 |
// 'component' => 'SalesforceIntegrationSettings', |
| 99 |
// 'icon' => 'salesforce', |
| 100 |
// 'description' => 'salesforce_description', |
| 101 |
// 'category' => 'CRM', |
| 102 |
// 'requiresAuth' => true, |
| 103 |
// 'plan' => 'agency', |
| 104 |
// ]); |
| 105 |
} |
| 106 |
} |
| 107 |
|