woocommerce-paypal-payments/modules/ppcp-compat/services.php

90 lines
2.8 KiB
PHP
Raw Normal View History

2021-07-15 06:51:37 -05:00
<?php
/**
* The compatibility module services.
*
* @package WooCommerce\PayPalCommerce\Compat
*/
declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\Compat;
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
2022-10-03 18:19:35 +04:00
use WooCommerce\PayPalCommerce\Compat\Assets\CompatAssets;
2021-10-13 15:02:10 +03:00
2021-07-27 14:34:36 -05:00
return array(
2023-09-01 18:42:27 +04:00
'compat.ppec.mock-gateway' => static function( $container ) {
2021-07-27 14:34:36 -05:00
$settings = $container->get( 'wcgateway.settings' );
$title = $settings->has( 'title' ) ? $settings->get( 'title' ) : __( 'PayPal', 'woocommerce-paypal-payments' );
$title = sprintf(
/* Translators: placeholder is the gateway name. */
__( '%s (Legacy)', 'woocommerce-paypal-payments' ),
$title
);
return new PPEC\MockGateway( $title );
},
2023-09-01 18:42:27 +04:00
'compat.ppec.subscriptions-handler' => static function ( ContainerInterface $container ) {
$ppcp_renewal_handler = $container->get( 'subscription.renewal-handler' );
$gateway = $container->get( 'compat.ppec.mock-gateway' );
return new PPEC\SubscriptionsHandler( $ppcp_renewal_handler, $gateway );
},
2023-09-01 18:42:27 +04:00
'compat.ppec.settings_importer' => static function( ContainerInterface $container ) : PPEC\SettingsImporter {
2021-07-14 15:06:32 -05:00
$settings = $container->get( 'wcgateway.settings' );
return new PPEC\SettingsImporter( $settings );
},
2023-09-01 18:42:27 +04:00
'compat.plugin-script-names' => static function( ContainerInterface $container ) : array {
return array(
'ppcp-smart-button',
'ppcp-oxxo',
'ppcp-pay-upon-invoice',
'ppcp-vaulting-myaccount-payments',
'ppcp-gateway-settings',
'ppcp-webhooks-status-page',
'ppcp-tracking',
2023-05-11 14:36:41 +02:00
'ppcp-fraudnet',
2023-07-25 13:17:32 +04:00
'ppcp-tracking-compat',
2023-06-06 12:24:05 +02:00
'ppcp-clear-db',
);
},
2023-09-01 18:42:27 +04:00
'compat.gzd.is_supported_plugin_version_active' => function (): bool {
2022-10-03 18:19:35 +04:00
return function_exists( 'wc_gzd_get_shipments_by_order' ); // 3.0+
},
2023-07-25 13:17:32 +04:00
'compat.wc_shipment_tracking.is_supported_plugin_version_active' => function (): bool {
return class_exists( 'WC_Shipment_Tracking' );
},
2023-09-01 18:42:27 +04:00
'compat.ywot.is_supported_plugin_version_active' => function (): bool {
return function_exists( 'yith_ywot_init' );
},
'compat.module.url' => static function ( ContainerInterface $container ): string {
2022-10-03 18:19:35 +04:00
/**
* The path cannot be false.
*
* @psalm-suppress PossiblyFalseArgument
*/
return plugins_url(
'/modules/ppcp-compat/',
dirname( realpath( __FILE__ ), 3 ) . '/woocommerce-paypal-payments.php'
);
},
2023-09-01 18:42:27 +04:00
'compat.assets' => function( ContainerInterface $container ) : CompatAssets {
2022-10-03 18:19:35 +04:00
return new CompatAssets(
$container->get( 'compat.module.url' ),
$container->get( 'ppcp.asset-version' ),
2023-07-25 13:17:32 +04:00
$container->get( 'compat.gzd.is_supported_plugin_version_active' ),
$container->get( 'compat.wc_shipment_tracking.is_supported_plugin_version_active' )
2022-10-03 18:19:35 +04:00
);
},
2021-07-27 14:34:36 -05:00
);