From a42c7e56fb5ddceebd1e4e2951358bf243188af9 Mon Sep 17 00:00:00 2001 From: Thijmen Wijers Date: Fri, 16 Feb 2024 13:27:46 +0100 Subject: [PATCH] feedback --- composer.json | 2 +- config/pdk.php | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/composer.json b/composer.json index 6d78bd9e..ced1f098 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "license": "MIT", "type": "prestashop-module", "require": { - "myparcelnl/pdk": "2.32.0", + "myparcelnl/pdk": "^2.0.0", "php": ">=7.4.0" }, "require-dev": { diff --git a/config/pdk.php b/config/pdk.php index 65a1996b..418e576d 100644 --- a/config/pdk.php +++ b/config/pdk.php @@ -82,15 +82,6 @@ use function DI\get; use function DI\value; -$comparePsVersion = '1.8.0'; -$currentPsVersion = constant('_PS_VERSION_'); - -if (version_compare($currentPsVersion, $comparePsVersion, '<')) { - $guzzleAdapter = Guzzle5ClientAdapter::class; -} else { - $guzzleAdapter = Guzzle7ClientAdapter::class; -} - return [ 'defaultCutoffTime' => value('17:00'), 'defaultCutoffTimeSameDay' => value('10:00'), @@ -162,7 +153,17 @@ /** * Miscellaneous */ - ClientAdapterInterface::class => get($guzzleAdapter), + ClientAdapterInterface::class => factory(function () { + $comparePsVersion = '1.8.0'; + $currentPsVersion = constant('_PS_VERSION_'); + + if (version_compare($currentPsVersion, $comparePsVersion, '<')) { + return get(Guzzle5ClientAdapter::class); + } + + return get(Guzzle7ClientAdapter::class); + }), + LoggerInterface::class => get(PsLogger::class), MigrationServiceInterface::class => get(PsMigrationService::class), ScriptServiceInterface::class => get(PsScriptService::class),