autowire( NoticeAdminNewInstall::class ), NoticeApiKeyRejected::class => autowire( NoticeApiKeyRejected::class ), SettingsHeader::class => autowire( SettingsHeader::class ), NoticeAdminDependency::class => autowire( NoticeAdminDependency::class ), NoticeGatewayNotAvailable::class => autowire( NoticeGatewayNotAvailable::class ), NoticeGatewayNotAvailableApi::class => autowire( NoticeGatewayNotAvailableApi::class ), NoticeGatewayNotEnabledMonei::class => autowire( NoticeGatewayNotEnabledMonei::class ), // array of [ 'short-template-name' => ] TemplateManager::class => create( TemplateManager::class ) ->constructor( array( 'notice-admin-new-install' => get( NoticeAdminNewInstall::class ), 'notice-admin-api-key-rejected' => get( NoticeApiKeyRejected::class ), 'monei-settings-header' => get( SettingsHeader::class ), 'notice-admin-dependency' => get( NoticeAdminDependency::class ), 'notice-admin-gateway-not-available' => get( NoticeGatewayNotAvailable::class ), 'notice-admin-gateway-not-available-api' => get( NoticeGatewayNotAvailableApi::class ), 'notice-admin-gateway-not-enabled-monei' => get( NoticeGatewayNotEnabledMonei::class ), ) ), ApiKeyService::class => autowire( ApiKeyService::class ), MoneiSdkClientFactory::class => autowire( MoneiSdkClientFactory::class ) ->constructor( get( ApiKeyService::class ) ), PaymentMethodsRepository::class => factory( function ( ApiKeyService $apiKeyService, MoneiSdkClientFactory $sdkClientFactory ) { return new PaymentMethodsRepository( $apiKeyService->get_account_id(), $sdkClientFactory->get_client() ); } ), PaymentMethodsService::class => create( PaymentMethodsService::class ) ->constructor( get( PaymentMethodsRepository::class ) ), CardBrandHelper::class => create( CardBrandHelper::class ) ->constructor( get( PaymentMethodsService::class ) ), MoneiPaymentServices::class => autowire( MoneiPaymentServices::class ), MoneiStatusCodeHandler::class => autowire( MoneiStatusCodeHandler::class ), PaymentMethodFormatter::class => autowire( PaymentMethodFormatter::class ), BlockSupportService::class => create( BlockSupportService::class ) ->constructor( $blocksPath, $blockNamespacePrefix ), MoneiApplePayVerificationService::class => autowire( MoneiApplePayVerificationService::class ) ->constructor( get( MoneiPaymentServices::class ) ), ExpressCartBackup::class => autowire( ExpressCartBackup::class ), ExpressCheckoutAjaxHandler::class => autowire( ExpressCheckoutAjaxHandler::class ), ExpressCheckoutAssets::class => autowire( ExpressCheckoutAssets::class ), WooCommerceSubscriptionsHandler::class => create( WooCommerceSubscriptionsHandler::class, )->constructor( get( MoneiSdkClientFactory::class ) ), YithSubscriptionPluginHandler::class => autowire( YithSubscriptionPluginHandler::class ), SubscriptionService::class => autowire( SubscriptionService::class ) ->constructorParameter( 'wooHandler', get( WooCommerceSubscriptionsHandler::class ) ) ->constructorParameter( 'yithHandler', get( YithSubscriptionPluginHandler::class ) ), ); // Dynamically load all gateway classes in the folder foreach ( glob( $gatewayPath . '/*.php' ) as $file ) { $className = $gatewayNamespacePrefix . pathinfo( $file, PATHINFO_FILENAME ); if ( class_exists( $className ) ) { $definitions[ $className ] = autowire(); } } // Dynamically register block support classes foreach ( glob( $blocksPath . '/*BlocksSupport.php' ) as $file ) { $blockClassName = $blockNamespacePrefix . pathinfo( $file, PATHINFO_FILENAME ); $gatewayNamePrefix = 'WCGateway'; if ( class_exists( $blockClassName ) ) { // Derive the corresponding gateway class name $gatewayClassName = $gatewayNamespacePrefix . $gatewayNamePrefix . str_replace( 'BlocksSupport', '', pathinfo( $file, PATHINFO_FILENAME ) ); // Register the block support class with the gateway as a dependency $definitions[ $blockClassName ] = autowire() ->constructorParameter( 'gateway', get( $gatewayClassName ) ); // Inject CardBrandHelper only for CC blocks support if ( $blockClassName === 'Monei\\Gateways\\Blocks\\MoneiCCBlocksSupport' ) { $definitions[ $blockClassName ] = $definitions[ $blockClassName ] ->constructorParameter( 'cardBrandHelper', get( CardBrandHelper::class ) ); } } } return $definitions;