Skip to content

Commit

Permalink
Rename gateway instances service to deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaymo committed Dec 18, 2024
1 parent ed2e1e9 commit e26ae66
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/Assets/AssetsModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ protected function setupModuleActions(ContainerInterface $container): void
$pluginPath = $container->get('shared.plugin_path');
/** @var Settings */
$settingsHelper = $container->get('settings.settings_helper');
$gatewayInstances = $container->get('gateway.instances');
$gatewayInstances = $container->get('__deprecated.gateway_helpers');

/** Add support to Mollie blocks for Woocommerce checkout blocks functionality */
//https://github.com/woocommerce/woocommerce-blocks/blob/trunk/docs/third-party-developers/extensibility/checkout-payment-methods/payment-method-integration.md#putting-it-all-together
Expand Down Expand Up @@ -588,7 +588,7 @@ function () use ($container, $hasBlocksEnabled, $settingsHelper, $pluginUrl, $pl

if ($hasBlocksEnabled) {
/** @var array */
$gatewayInstances = $container->get('gateway.instances');
$gatewayInstances = $container->get('__deprecated.gateway_helpers');
self::registerBlockScripts($pluginUrl, $pluginPath);
add_action('wp_enqueue_scripts', function () use ($dataService, $gatewayInstances) {
$this->enqueueBlockCheckoutScripts($dataService, $gatewayInstances);
Expand Down
8 changes: 4 additions & 4 deletions src/Gateway/GatewayModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ static function () {

// Set order to paid and processed when eventually completed without Mollie
add_action('woocommerce_payment_complete', [$this, 'setOrderPaidByOtherGateway'], 10, 1);
$appleGateway = isset($container->get('gateway.instances')['mollie_wc_gateway_applepay']) ? $container->get(
'gateway.instances'
$appleGateway = isset($container->get('__deprecated.gateway_helpers')['mollie_wc_gateway_applepay']) ? $container->get(
'__deprecated.gateway_helpers'
)['mollie_wc_gateway_applepay'] : false;
$notice = $container->get(AdminNotice::class);
assert($notice instanceof AdminNotice);
Expand All @@ -150,8 +150,8 @@ static function () {
$this->mollieApplePayDirectHandling($notice, $logger, $apiHelper, $settingsHelper, $appleGateway);
}

$paypalGateway = isset($container->get('gateway.instances')['mollie_wc_gateway_paypal']) ? $container->get(
'gateway.instances'
$paypalGateway = isset($container->get('__deprecated.gateway_helpers')['mollie_wc_gateway_paypal']) ? $container->get(
'__deprecated.gateway_helpers'
)['mollie_wc_gateway_paypal'] : false;
if ($paypalGateway) {
$this->molliePayPalButtonHandling($paypalGateway, $notice, $logger, $pluginUrl);
Expand Down
3 changes: 1 addition & 2 deletions src/Gateway/MolliePaymentGatewayHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
use WC_Payment_Gateway;
use WP_Error;

class MolliePaymentGatewayHandler extends WC_Payment_Gateway implements MolliePaymentGatewayI
class MolliePaymentGatewayHandler implements MolliePaymentGatewayI
{
/**
* @var bool
Expand Down Expand Up @@ -86,7 +86,6 @@ class MolliePaymentGatewayHandler extends WC_Payment_Gateway implements MolliePa
* @var string
*/
protected $pluginId;
private RefundProcessor $refundProcessor;

/**
*
Expand Down
2 changes: 1 addition & 1 deletion src/Gateway/Voucher/VoucherModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function services(): array
*/
public function run(ContainerInterface $container): bool
{
$gatewayInstances = $container->get('gateway.instances');
$gatewayInstances = $container->get('__deprecated.gateway_helpers');
$voucherGateway = $gatewayInstances['mollie_wc_gateway_voucher'] ?? false;
$voucher = $voucherGateway && $voucherGateway->enabled === 'yes';

Expand Down
12 changes: 6 additions & 6 deletions src/Gateway/inc/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
'gateway.classnames' => static function (): array {
return SharedDataDictionary::GATEWAY_CLASSNAMES;
},
'gateway.instances' => static function (ContainerInterface $container): array {
'__deprecated.gateway_helpers' => static function (ContainerInterface $container): array {
$oldGatewayBuilder = new OldGatewayBuilder();
return $oldGatewayBuilder->instantiatePaymentMethodGateways($container);
},
Expand Down Expand Up @@ -168,7 +168,7 @@
},
'payment_gateway.getRefundProcessor' => static function (ContainerInterface $container): callable {
return static function (string $gatewayId) use ($container): RefundProcessor {
$oldGatewayInstances = $container->get('gateway.instances');
$oldGatewayInstances = $container->get('__deprecated.gateway_helpers');

if (!isset($oldGatewayInstances[$gatewayId])) {
return $container->get('payment_gateways.noop_refund_processor');
Expand Down Expand Up @@ -212,7 +212,7 @@
},
'payment_gateway.getOldGatewayInstances' => static function (ContainerInterface $container): callable {
return static function () use ($container): array {
return $container->get('gateway.instances');
return $container->get('__deprecated.gateway_helpers');
};
},
'gateway.subscriptionHooks' => static function (): array {
Expand Down Expand Up @@ -242,7 +242,7 @@
return $container->get('payment_gateways.noop_payment_request_validator');
};
$dynamicServices["payment_gateway.$gatewayId.payment_processor"] = static function (ContainerInterface $container) use ($gatewayId): PaymentService {
$oldGatewayInstances = $container->get('gateway.instances');
$oldGatewayInstances = $container->get('__deprecated.gateway_helpers');
$gateway = $oldGatewayInstances[$gatewayId];
$paymentService = $container->get(PaymentService::class);
$paymentService->setGateway($gateway);
Expand Down Expand Up @@ -279,7 +279,7 @@
$methodId = substr($gatewayId, strrpos($gatewayId, '_') + 1);
$paymentMethod = $paymentMethods[$methodId];

$oldGatewayInstances = $container->get('gateway.instances');
$oldGatewayInstances = $container->get('__deprecated.gateway_helpers');
//not all payment methods have a gateway
if (!isset($oldGatewayInstances[$gatewayId])) {
return new NoopPaymentFieldsRenderer();
Expand Down Expand Up @@ -318,7 +318,7 @@
return empty($description) ? false : $description;
};
$dynamicServices["payment_gateway.$gatewayId.availability_callback"] = new Factory(
['gateway.instances'],
['__deprecated.gateway_helpers'],
static function (array $gatewayInstances) use($gatewayId): callable {
return static function () use ($gatewayInstances, $gatewayId): bool {
return $gatewayInstances[$gatewayId]->is_available();
Expand Down
4 changes: 2 additions & 2 deletions src/Payment/PaymentModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public function onMollieReturn($container)

$gateway = wc_get_payment_gateway_by_order($order);
$orderId = $order->get_id();
$oldGatewayInstances = $container->get('gateway.instances');
$oldGatewayInstances = $container->get('__deprecated.gateway_helpers');
$mollieGatewayHelper = $oldGatewayInstances[$gateway->id];

if (!$gateway) {
Expand Down Expand Up @@ -312,7 +312,7 @@ public function onOrderDetails(WC_Order $order, ContainerInterface $container)
}


$oldGatewayInstances = $container->get('gateway.instances');
$oldGatewayInstances = $container->get('__deprecated.gateway_helpers');
$mollieGatewayHelper = $oldGatewayInstances[$gateway->id];
$mollieGatewayHelper->displayInstructions($order);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Settings/SettingsModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ function () use ($optionName, $defaultAdvancedOptions, $defaultComponentsOptions
$this->maybeTestModeNotice();
});

$gateways = $container->get('gateway.instances');
$gateways = $container->get('__deprecated.gateway_helpers');
$isSDDGatewayEnabled = $container->get('gateway.isSDDGatewayEnabled');
$this->initMollieSettingsPage($isSDDGatewayEnabled, $gateways, $pluginPath, $pluginUrl, $paymentMethods);
add_action(
Expand Down

0 comments on commit e26ae66

Please sign in to comment.