| @@ -9,8 +9,10 @@ | ||
| 9 | 9 | use IvyForms\Services\Menu\MenuService; |
| 10 | 10 | use IvyForms\Services\Integrations\PluginInstaller; |
| 11 | 11 | use IvyForms\Services\Integrations\IntegrationRegistry; |
| 12 | 12 | use IvyForms\Services\Integrations\IntegrationService; |
| 13 | +use IvyForms\Services\Permissions\PermissionResolver; | |
| 14 | +use IvyForms\Services\Permissions\RoutePermissionService; | |
| 13 | 15 | use IvyForms\Controllers\Integrations\InstallPluginController; |
| 14 | 16 | use IvyForms\Controllers\Integration\GetAllIntegrationsController; |
| 15 | 17 | use IvyForms\Controllers\Integration\GetIntegrationController; |
| 16 | 18 | use IvyForms\Controllers\Form\ExportFormController; |
| @@ -16,19 +18,55 @@ | ||
| 16 | 18 | use IvyForms\Controllers\Form\ExportFormController; |
| 17 | 19 | use IvyForms\Controllers\Form\ImportFormController; |
| 18 | 20 | use IvyForms\Services\Form\FormService; |
| 19 | 21 | use IvyForms\Services\Form\FormImportExportService; |
| 22 | +use IvyForms\Services\Entry\EntryService; | |
| 23 | +use IvyForms\Services\Field\FieldDuplicateValidationService; | |
| 20 | 24 | use IvyForms\Services\Field\FieldService; |
| 25 | +use IvyForms\Services\Mailer\MailerService; | |
| 21 | 26 | use IvyForms\Services\Notification\NotificationService; |
| 27 | +use IvyForms\Services\Security\SecurityService; | |
| 22 | 28 | use IvyForms\Services\Confirmation\ConfirmationService; |
| 29 | +use IvyForms\Services\Submission\FormSubmissionService; | |
| 23 | 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; | |
| 24 | 62 | |
| 25 | 63 | return [ |
| 26 | 64 | |
| 27 | - MenuManager::class => function () { | |
| 65 | + MenuManager::class => function ($container) { | |
| 28 | 66 | return new MenuManager( |
| 29 | - new MenuService(), | |
| 30 | - new MenuMapper() | |
| 67 | + new MenuService($container->get(RoutePermissionService::class)), | |
| 68 | + new MenuMapper($container->get(PermissionResolver::class)) | |
| 31 | 69 | ); |
| 32 | 70 | }, |
| 33 | 71 | |
| 34 | 72 | PluginInstaller::class => function () { |
| @@ -46,9 +84,10 @@ | ||
| 46 | 84 | }, |
| 47 | 85 | |
| 48 | 86 | IntegrationService::class => function ($container) { |
| 49 | 87 | return new IntegrationService( |
| 50 | - $container->get(IntegrationRegistry::class) | |
| 88 | + $container->get(IntegrationRegistry::class), | |
| 89 | + $container->get(\IvyForms\Services\GoogleSheets\Hooks\InitializationHook::class) | |
| 51 | 90 | ); |
| 52 | 91 | }, |
| 53 | 92 | SubmissionDataFormatterService::class => function () { |
| 54 | 93 | return new SubmissionDataFormatterService(); |
| @@ -53,20 +92,163 @@ | ||
| 53 | 92 | SubmissionDataFormatterService::class => function () { |
| 54 | 93 | return new SubmissionDataFormatterService(); |
| 55 | 94 | }, |
| 56 | 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 | + | |
| 57 | 237 | FormImportExportService::class => function ($container) { |
| 58 | 238 | return new FormImportExportService( |
| 59 | 239 | $container->get(FormService::class), |
| 60 | 240 | $container->get(FieldService::class), |
| 61 | 241 | $container->get(NotificationService::class), |
| 62 | - $container->get(ConfirmationService::class) | |
| 242 | + $container->get(ConfirmationService::class), | |
| 243 | + $container->get(\IvyForms\Services\Permissions\AccessRulesFormScopeExtender::class) | |
| 63 | 244 | ); |
| 64 | 245 | }, |
| 65 | 246 | |
| 66 | 247 | ExportFormController::class => function ($container) { |
| 67 | 248 | return new ExportFormController( |
| 68 | - $container->get(FormImportExportService::class) | |
| 249 | + $container->get(FormImportExportService::class), | |
| 250 | + $container->get(RoutePermissionService::class) | |
| 69 | 251 | ); |
| 70 | 252 | }, |
| 71 | 253 | |
| 72 | 254 | ImportFormController::class => function ($container) { |
| @@ -71,8 +253,39 @@ | ||
| 71 | 253 | |
| 72 | 254 | ImportFormController::class => function ($container) { |
| 73 | 255 | return new ImportFormController( |
| 74 | 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) | |
| 75 | 288 | ); |
| 76 | 289 | }, |
| 77 | 290 | |
| 78 | 291 | // GetAllIntegrationsController::class => function ($container) { |