| 1 |
<?php |
| 2 |
|
| 3 |
if (!defined('ABSPATH')) { |
| 4 |
exit; // Exit if accessed directly |
| 5 |
} |
| 6 |
|
| 7 |
use IvyForms\Services\Menu\MenuManager; |
| 8 |
use IvyForms\Services\Menu\MenuMapper; |
| 9 |
use IvyForms\Services\Menu\MenuService; |
| 10 |
use IvyForms\Services\Integrations\PluginInstaller; |
| 11 |
use IvyForms\Services\Integrations\IntegrationRegistry; |
| 12 |
use IvyForms\Services\Integrations\IntegrationService; |
| 13 |
use IvyForms\Services\Permissions\PermissionResolver; |
| 14 |
use IvyForms\Services\Permissions\RoutePermissionService; |
| 15 |
use IvyForms\Controllers\Integrations\InstallPluginController; |
| 16 |
use IvyForms\Controllers\Integration\GetAllIntegrationsController; |
| 17 |
use IvyForms\Controllers\Integration\GetIntegrationController; |
| 18 |
use IvyForms\Controllers\Form\ExportFormController; |
| 19 |
use IvyForms\Controllers\Form\ImportFormController; |
| 20 |
use IvyForms\Services\Form\FormService; |
| 21 |
use IvyForms\Services\Form\FormImportExportService; |
| 22 |
use IvyForms\Services\Entry\EntryService; |
| 23 |
use IvyForms\Services\Field\FieldDuplicateValidationService; |
| 24 |
use IvyForms\Services\Field\FieldService; |
| 25 |
use IvyForms\Services\Mailer\MailerService; |
| 26 |
use IvyForms\Services\Notification\NotificationService; |
| 27 |
use IvyForms\Services\Security\SecurityService; |
| 28 |
use IvyForms\Services\Confirmation\ConfirmationService; |
| 29 |
use IvyForms\Services\Submission\FormSubmissionService; |
| 30 |
use IvyForms\Services\Submission\SubmissionDataFormatterService; |
| 31 |
use IvyForms\Services\Submission\SubmissionUploadService; |
| 32 |
use IvyForms\Services\GoogleSheets\Helpers\GoogleSheetsRequestSanitizer; |
| 33 |
use IvyForms\Services\GoogleSheets\Hooks\GoogleSheetsEntryHooks; |
| 34 |
use IvyForms\Services\GoogleSheets\Hooks\GoogleSheetsFormHooks; |
| 35 |
use IvyForms\Services\GoogleSheets\Hooks\InitializationHook as GoogleSheetsInitializationHook; |
| 36 |
use IvyForms\Repository\GoogleSheets\GoogleSheetsRepositoryInterface; |
| 37 |
use IvyForms\Services\GoogleSheets\GoogleSheetsDispatcherService; |
| 38 |
use IvyForms\Services\GoogleSheets\GoogleSheetsManagerService; |
| 39 |
use IvyForms\Services\GoogleSheets\GoogleSheetsService; |
| 40 |
use IvyForms\Controllers\GoogleSheets\GoogleSheetsConnectController; |
| 41 |
use IvyForms\Controllers\GoogleSheets\GoogleSheetsOAuthCallbackController; |
| 42 |
use IvyForms\Controllers\GoogleSheets\GoogleSheetsCreateController; |
| 43 |
use IvyForms\Controllers\GoogleSheets\GoogleSheetsDeleteController; |
| 44 |
use IvyForms\Controllers\GoogleSheets\GoogleSheetsDisconnectController; |
| 45 |
use IvyForms\Controllers\GoogleSheets\GoogleSheetsListColumnsController; |
| 46 |
use IvyForms\Controllers\GoogleSheets\GoogleSheetsListIntegrationsController; |
| 47 |
use IvyForms\Controllers\GoogleSheets\GoogleSheetsListSpreadsheetsController; |
| 48 |
use IvyForms\Controllers\GoogleSheets\GoogleSheetsListWorksheetsController; |
| 49 |
use IvyForms\Controllers\GoogleSheets\GoogleSheetsPickerConfigController; |
| 50 |
use IvyForms\Controllers\GoogleSheets\GoogleSheetsStatusController; |
| 51 |
use IvyForms\Controllers\GoogleSheets\GoogleSheetsUpdateController; |
| 52 |
use IvyForms\Controllers\GoogleSheets\GoogleSheetsUpdateStatusController; |
| 53 |
use IvyForms\Services\Settings\SettingsService; |
| 54 |
use IvyForms\Services\Usage\UsageTrackingService; |
| 55 |
use IvyForms\Vendor\Melograno\UsageTracker\Collectors\Plugin\IvyFormsCollector; |
| 56 |
use IvyForms\Services\Payment\FormSubmissionPaymentService; |
| 57 |
use IvyForms\Services\Payment\OrderManager; |
| 58 |
use IvyForms\Services\Payment\PaymentAmountCalculator; |
| 59 |
use IvyForms\Services\Payment\PaymentGatewayRegistry; |
| 60 |
use IvyForms\Services\Payment\PaymentManager; |
| 61 |
use IvyForms\Services\Payment\SquarePaymentGateway; |
| 62 |
|
| 63 |
return [ |
| 64 |
|
| 65 |
MenuManager::class => function ($container) { |
| 66 |
return new MenuManager( |
| 67 |
new MenuService($container->get(RoutePermissionService::class)), |
| 68 |
new MenuMapper($container->get(PermissionResolver::class)) |
| 69 |
); |
| 70 |
}, |
| 71 |
|
| 72 |
PluginInstaller::class => function () { |
| 73 |
return new PluginInstaller(); |
| 74 |
}, |
| 75 |
|
| 76 |
InstallPluginController::class => function ($container) { |
| 77 |
return new InstallPluginController( |
| 78 |
$container->get(PluginInstaller::class) |
| 79 |
); |
| 80 |
}, |
| 81 |
|
| 82 |
IntegrationRegistry::class => function () { |
| 83 |
return new IntegrationRegistry(); |
| 84 |
}, |
| 85 |
|
| 86 |
IntegrationService::class => function ($container) { |
| 87 |
return new IntegrationService( |
| 88 |
$container->get(IntegrationRegistry::class), |
| 89 |
$container->get(\IvyForms\Services\GoogleSheets\Hooks\InitializationHook::class) |
| 90 |
); |
| 91 |
}, |
| 92 |
SubmissionDataFormatterService::class => function () { |
| 93 |
return new SubmissionDataFormatterService(); |
| 94 |
}, |
| 95 |
|
| 96 |
SubmissionUploadService::class => function () { |
| 97 |
return new SubmissionUploadService(); |
| 98 |
}, |
| 99 |
|
| 100 |
FormSubmissionService::class => function ($container) { |
| 101 |
return new FormSubmissionService( |
| 102 |
$container->get(SubmissionUploadService::class), |
| 103 |
$container->get(FormService::class), |
| 104 |
$container->get(FieldService::class), |
| 105 |
$container->get(FieldDuplicateValidationService::class), |
| 106 |
$container->get(SecurityService::class), |
| 107 |
$container->get(EntryService::class), |
| 108 |
$container->get(NotificationService::class), |
| 109 |
$container->get(MailerService::class), |
| 110 |
$container->get(ConfirmationService::class), |
| 111 |
$container->get(FormSubmissionPaymentService::class) |
| 112 |
); |
| 113 |
}, |
| 114 |
|
| 115 |
GoogleSheetsRequestSanitizer::class => static function () { |
| 116 |
return new GoogleSheetsRequestSanitizer(); |
| 117 |
}, |
| 118 |
|
| 119 |
GoogleSheetsService::class => static function ($container) { |
| 120 |
return new GoogleSheetsService( |
| 121 |
$container->get(SettingsService::class) |
| 122 |
); |
| 123 |
}, |
| 124 |
|
| 125 |
GoogleSheetsManagerService::class => static function ($container) { |
| 126 |
return new GoogleSheetsManagerService( |
| 127 |
$container->get(GoogleSheetsRepositoryInterface::class) |
| 128 |
); |
| 129 |
}, |
| 130 |
|
| 131 |
GoogleSheetsDispatcherService::class => static function ($container) { |
| 132 |
return new GoogleSheetsDispatcherService( |
| 133 |
$container->get(GoogleSheetsRepositoryInterface::class), |
| 134 |
$container->get(GoogleSheetsService::class), |
| 135 |
$container->get(SubmissionDataFormatterService::class) |
| 136 |
); |
| 137 |
}, |
| 138 |
|
| 139 |
GoogleSheetsEntryHooks::class => static function ($container) { |
| 140 |
return new GoogleSheetsEntryHooks( |
| 141 |
$container->get(GoogleSheetsDispatcherService::class) |
| 142 |
); |
| 143 |
}, |
| 144 |
|
| 145 |
GoogleSheetsFormHooks::class => static function ($container) { |
| 146 |
return new GoogleSheetsFormHooks( |
| 147 |
$container->get(GoogleSheetsRepositoryInterface::class) |
| 148 |
); |
| 149 |
}, |
| 150 |
|
| 151 |
GoogleSheetsInitializationHook::class => static function ($container) { |
| 152 |
return new GoogleSheetsInitializationHook( |
| 153 |
$container->get(SettingsService::class) |
| 154 |
); |
| 155 |
}, |
| 156 |
|
| 157 |
GoogleSheetsConnectController::class => static function ($container) { |
| 158 |
return new GoogleSheetsConnectController( |
| 159 |
$container->get(GoogleSheetsService::class) |
| 160 |
); |
| 161 |
}, |
| 162 |
|
| 163 |
GoogleSheetsOAuthCallbackController::class => static function ($container) { |
| 164 |
return new GoogleSheetsOAuthCallbackController( |
| 165 |
$container->get(GoogleSheetsService::class) |
| 166 |
); |
| 167 |
}, |
| 168 |
|
| 169 |
GoogleSheetsDisconnectController::class => static function ($container) { |
| 170 |
return new GoogleSheetsDisconnectController( |
| 171 |
$container->get(GoogleSheetsService::class) |
| 172 |
); |
| 173 |
}, |
| 174 |
|
| 175 |
GoogleSheetsStatusController::class => static function ($container) { |
| 176 |
return new GoogleSheetsStatusController( |
| 177 |
$container->get(GoogleSheetsService::class) |
| 178 |
); |
| 179 |
}, |
| 180 |
|
| 181 |
GoogleSheetsPickerConfigController::class => static function ($container) { |
| 182 |
return new GoogleSheetsPickerConfigController( |
| 183 |
$container->get(GoogleSheetsService::class) |
| 184 |
); |
| 185 |
}, |
| 186 |
|
| 187 |
GoogleSheetsListSpreadsheetsController::class => static function ($container) { |
| 188 |
return new GoogleSheetsListSpreadsheetsController( |
| 189 |
$container->get(GoogleSheetsService::class) |
| 190 |
); |
| 191 |
}, |
| 192 |
|
| 193 |
GoogleSheetsListWorksheetsController::class => static function ($container) { |
| 194 |
return new GoogleSheetsListWorksheetsController( |
| 195 |
$container->get(GoogleSheetsService::class) |
| 196 |
); |
| 197 |
}, |
| 198 |
|
| 199 |
GoogleSheetsListColumnsController::class => static function ($container) { |
| 200 |
return new GoogleSheetsListColumnsController( |
| 201 |
$container->get(GoogleSheetsService::class) |
| 202 |
); |
| 203 |
}, |
| 204 |
|
| 205 |
GoogleSheetsListIntegrationsController::class => static function ($container) { |
| 206 |
return new GoogleSheetsListIntegrationsController( |
| 207 |
$container->get(GoogleSheetsManagerService::class) |
| 208 |
); |
| 209 |
}, |
| 210 |
|
| 211 |
GoogleSheetsCreateController::class => static function ($container) { |
| 212 |
return new GoogleSheetsCreateController( |
| 213 |
$container->get(GoogleSheetsManagerService::class), |
| 214 |
$container->get(GoogleSheetsRequestSanitizer::class) |
| 215 |
); |
| 216 |
}, |
| 217 |
|
| 218 |
GoogleSheetsUpdateController::class => static function ($container) { |
| 219 |
return new GoogleSheetsUpdateController( |
| 220 |
$container->get(GoogleSheetsManagerService::class), |
| 221 |
$container->get(GoogleSheetsRequestSanitizer::class) |
| 222 |
); |
| 223 |
}, |
| 224 |
|
| 225 |
GoogleSheetsUpdateStatusController::class => static function ($container) { |
| 226 |
return new GoogleSheetsUpdateStatusController( |
| 227 |
$container->get(GoogleSheetsManagerService::class) |
| 228 |
); |
| 229 |
}, |
| 230 |
|
| 231 |
GoogleSheetsDeleteController::class => static function ($container) { |
| 232 |
return new GoogleSheetsDeleteController( |
| 233 |
$container->get(GoogleSheetsManagerService::class) |
| 234 |
); |
| 235 |
}, |
| 236 |
|
| 237 |
FormImportExportService::class => function ($container) { |
| 238 |
return new FormImportExportService( |
| 239 |
$container->get(FormService::class), |
| 240 |
$container->get(FieldService::class), |
| 241 |
$container->get(NotificationService::class), |
| 242 |
$container->get(ConfirmationService::class), |
| 243 |
$container->get(\IvyForms\Services\Permissions\AccessRulesFormScopeExtender::class) |
| 244 |
); |
| 245 |
}, |
| 246 |
|
| 247 |
ExportFormController::class => function ($container) { |
| 248 |
return new ExportFormController( |
| 249 |
$container->get(FormImportExportService::class), |
| 250 |
$container->get(RoutePermissionService::class) |
| 251 |
); |
| 252 |
}, |
| 253 |
|
| 254 |
ImportFormController::class => function ($container) { |
| 255 |
return new ImportFormController( |
| 256 |
$container->get(FormImportExportService::class) |
| 257 |
); |
| 258 |
}, |
| 259 |
|
| 260 |
IvyFormsCollector::class => function () { |
| 261 |
return new IvyFormsCollector(); |
| 262 |
}, |
| 263 |
|
| 264 |
UsageTrackingService::class => function ($container) { |
| 265 |
return new UsageTrackingService($container->get(IvyFormsCollector::class)); |
| 266 |
}, |
| 267 |
|
| 268 |
PaymentGatewayRegistry::class => function ($container) { |
| 269 |
$registry = new PaymentGatewayRegistry(); |
| 270 |
$registry->register($container->get(SquarePaymentGateway::class)); |
| 271 |
|
| 272 |
/** |
| 273 |
* Allow Pro/addons to register additional payment gateways. |
| 274 |
* |
| 275 |
* The action receives the registry and PHP-DI container. |
| 276 |
*/ |
| 277 |
do_action('ivyforms/payment/register_gateways', $registry, $container); |
| 278 |
|
| 279 |
return $registry; |
| 280 |
}, |
| 281 |
|
| 282 |
FormSubmissionPaymentService::class => function ($container) { |
| 283 |
return new FormSubmissionPaymentService( |
| 284 |
$container->get(PaymentAmountCalculator::class), |
| 285 |
$container->get(PaymentManager::class), |
| 286 |
$container->get(OrderManager::class), |
| 287 |
$container->get(PaymentGatewayRegistry::class) |
| 288 |
); |
| 289 |
}, |
| 290 |
|
| 291 |
// GetAllIntegrationsController::class => function ($container) { |
| 292 |
// return new GetAllIntegrationsController( |
| 293 |
// $container->get(IntegrationRegistry::class) |
| 294 |
// ); |
| 295 |
// }, |
| 296 |
// |
| 297 |
// GetIntegrationController::class => function ($container) { |
| 298 |
// return new GetIntegrationController( |
| 299 |
// $container->get(IntegrationRegistry::class) |
| 300 |
// ); |
| 301 |
// }, |
| 302 |
]; |
| 303 |
|