diff --git a/src/Provider/PaymentOption/BancontactPaymentOptionProvider.php b/src/Provider/PaymentOption/BancontactPaymentOptionProvider.php index 82a3d12c8..3e57fdb25 100644 --- a/src/Provider/PaymentOption/BancontactPaymentOptionProvider.php +++ b/src/Provider/PaymentOption/BancontactPaymentOptionProvider.php @@ -43,7 +43,7 @@ use Mollie\Provider\OrderTotal\OrderTotalProviderInterface; use Mollie\Provider\PaymentFeeProviderInterface; use Mollie\Service\LanguageService; -use Mollie\Service\PaymentMethodLangService; +use Mollie\Service\PaymentMethodLangServiceInterface; use MolPaymentMethod; use PrestaShop\PrestaShop\Core\Payment\PaymentOption; use Tools; @@ -83,7 +83,7 @@ class BancontactPaymentOptionProvider implements PaymentOptionProviderInterface /** @var OrderTotalProviderInterface */ private $orderTotalProvider; - /** @var PaymentMethodLangService $multiLangService */ + /** @var PaymentMethodLangServiceInterface $multiLangService */ private $multiLangService; public function __construct( @@ -93,7 +93,7 @@ public function __construct( PaymentFeeProviderInterface $paymentFeeProvider, LanguageService $languageService, OrderTotalProviderInterface $orderTotalProvider, - PaymentMethodLangService $multiLangService + PaymentMethodLangServiceInterface $multiLangService ) { $this->module = $module; $this->context = $context; diff --git a/src/Provider/PaymentOption/BasePaymentOptionProvider.php b/src/Provider/PaymentOption/BasePaymentOptionProvider.php index 24081c9c2..acd21e00d 100644 --- a/src/Provider/PaymentOption/BasePaymentOptionProvider.php +++ b/src/Provider/PaymentOption/BasePaymentOptionProvider.php @@ -42,7 +42,7 @@ use Mollie\Provider\OrderTotal\OrderTotalProviderInterface; use Mollie\Provider\PaymentFeeProviderInterface; use Mollie\Service\LanguageService; -use Mollie\Service\PaymentMethodLangService; +use Mollie\Service\PaymentMethodLangServiceInterface; use MolPaymentMethod; use PrestaShop\PrestaShop\Core\Payment\PaymentOption; use Tools; @@ -81,7 +81,7 @@ class BasePaymentOptionProvider implements PaymentOptionProviderInterface private $languageService; /** @var OrderTotalProviderInterface */ private $orderTotalProvider; - /** @var PaymentMethodLangService $multiLangService */ + /** @var PaymentMethodLangServiceInterface $multiLangService */ private $multiLangService; public function __construct( @@ -91,7 +91,7 @@ public function __construct( PaymentFeeProviderInterface $paymentFeeProvider, LanguageService $languageService, OrderTotalProviderInterface $orderTotalProvider, - PaymentMethodLangService $multiLangService + PaymentMethodLangServiceInterface $multiLangService ) { $this->module = $module; $this->context = $context; diff --git a/src/Provider/PaymentOption/CreditCardPaymentOptionProvider.php b/src/Provider/PaymentOption/CreditCardPaymentOptionProvider.php index ef9308549..479270f7d 100644 --- a/src/Provider/PaymentOption/CreditCardPaymentOptionProvider.php +++ b/src/Provider/PaymentOption/CreditCardPaymentOptionProvider.php @@ -47,7 +47,6 @@ use Mollie\Provider\PaymentFeeProviderInterface; use Mollie\Repository\MolCustomerRepository; use Mollie\Service\LanguageService; -use Mollie\Service\PaymentMethodLangService; use Mollie\Utility\CustomerUtility; use MolPaymentMethod; use PrestaShop\PrestaShop\Core\Payment\PaymentOption; diff --git a/src/Provider/PaymentOption/CreditCardSingleClickPaymentOptionProvider.php b/src/Provider/PaymentOption/CreditCardSingleClickPaymentOptionProvider.php index 396fa61bb..67fcb5bdf 100644 --- a/src/Provider/PaymentOption/CreditCardSingleClickPaymentOptionProvider.php +++ b/src/Provider/PaymentOption/CreditCardSingleClickPaymentOptionProvider.php @@ -46,7 +46,7 @@ use Mollie\Provider\PaymentFeeProviderInterface; use Mollie\Repository\MolCustomerRepository; use Mollie\Service\LanguageService; -use Mollie\Service\PaymentMethodLangService; +use Mollie\Service\PaymentMethodLangServiceInterface; use Mollie\Utility\CustomerUtility; use MolPaymentMethod; use PrestaShop\PrestaShop\Core\Payment\PaymentOption; @@ -97,7 +97,7 @@ class CreditCardSingleClickPaymentOptionProvider implements PaymentOptionProvide private $customer; /** @var ConfigurationAdapter */ private $configurationAdapter; - /** @var PaymentMethodLangService $multiLangService */ + /** @var PaymentMethodLangServiceInterface $multiLangService */ private $multiLangService; public function __construct( @@ -110,7 +110,7 @@ public function __construct( MolCustomerRepository $customerRepository, Mollie\Adapter\Customer $customer, ConfigurationAdapter $configurationAdapter, - PaymentMethodLangService $multiLangService + PaymentMethodLangServiceInterface $multiLangService ) { $this->module = $module; $this->context = $context; diff --git a/src/Provider/PaymentOption/IdealPaymentOptionProvider.php b/src/Provider/PaymentOption/IdealPaymentOptionProvider.php index f283a36a5..92c67e5fa 100644 --- a/src/Provider/PaymentOption/IdealPaymentOptionProvider.php +++ b/src/Provider/PaymentOption/IdealPaymentOptionProvider.php @@ -43,7 +43,7 @@ use Mollie\Provider\PaymentFeeProviderInterface; use Mollie\Service\Content\TemplateParserInterface; use Mollie\Service\LanguageService; -use Mollie\Service\PaymentMethodLangService; +use Mollie\Service\PaymentMethodLangServiceInterface; use MolPaymentMethod; use PrestaShop\PrestaShop\Core\Payment\PaymentOption; use Tools; @@ -98,7 +98,7 @@ public function __construct( TemplateParserInterface $templateParser, LanguageService $languageService, OrderTotalProviderInterface $orderTotalProvider, - PaymentMethodLangService $multiLangService + PaymentMethodLangServiceInterface $multiLangService ) { $this->module = $module; $this->context = $context; diff --git a/src/Service/ApiService.php b/src/Service/ApiService.php index 316a36ca5..a396b0d0d 100644 --- a/src/Service/ApiService.php +++ b/src/Service/ApiService.php @@ -81,7 +81,7 @@ class ApiService implements ApiServiceInterface private $taxProvider; /** @var Context */ private $context; - /** @var PaymentMethodLangService */ + /** @var PaymentMethodLangServiceInterface */ private $multiLangService; public function __construct( @@ -93,7 +93,7 @@ public function __construct( Shop $shop, TaxCalculatorProvider $taxProvider, Context $context, - PaymentMethodLangService $multiLangService + PaymentMethodLangServiceInterface $multiLangService ) { $this->countryRepository = $countryRepository; $this->paymentMethodSortProvider = $paymentMethodSortProvider; diff --git a/src/Service/PaymentMethodLangService.php b/src/Service/PaymentMethodLangService.php index d912d03f6..d52ad3af2 100644 --- a/src/Service/PaymentMethodLangService.php +++ b/src/Service/PaymentMethodLangService.php @@ -19,7 +19,7 @@ exit; } -class PaymentMethodLangService +class PaymentMethodLangService implements PaymentMethodLangServiceInterface { /** @var MultiLangRepositoryInterface */ private $multiLangRepository; @@ -55,13 +55,6 @@ public function trans(string $idMethod): ?string return $this->multiLangRepository->getTextByLanguageAndMethod($this->context->getLanguageId(), $idMethod, $this->context->getShopId()); } - - /** - * Gets all translations for a payment method title - * - * @param string $idMethod - * @return array [id_lang => text] for instance: [74 => 'Apelo Pay', 68 => 'Apella Pia'] - */ public function getTransList(string $idMethod): array { $result = $this->multiLangRepository->getAllTranslationsByMethod($idMethod, $this->context->getLanguageId(), $this->context->getShopId()); diff --git a/src/Service/PaymentMethodLangServiceInterface.php b/src/Service/PaymentMethodLangServiceInterface.php new file mode 100644 index 000000000..9501b26ad --- /dev/null +++ b/src/Service/PaymentMethodLangServiceInterface.php @@ -0,0 +1,38 @@ + + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + * @codingStandardsIgnoreStart + */ + +namespace Mollie\Service; + +if (!defined('_PS_VERSION_')) { + exit; +} + +interface PaymentMethodLangServiceInterface +{ + /** + * Saves payment method title translation into database table `mol_payment_method_lang` + */ + public function savePaymentTitleTranslation(string $idPaymentMethod, int $langId, string $translation, int $idShop); + + /** + * Gets translated title by payment method id + */ + public function trans(string $idMethod): ?string; + + /** + * Gets all translations for a payment method title + * + * @param string $idMethod + * @return array [id_lang => text] for instance: [74 => 'Apelo Pay', 68 => 'Apella Pia'] + */ + public function getTransList(string $idMethod): array; +} diff --git a/src/Service/PaymentMethodService.php b/src/Service/PaymentMethodService.php index e055bcc71..28d8a5e12 100644 --- a/src/Service/PaymentMethodService.php +++ b/src/Service/PaymentMethodService.php @@ -116,7 +116,7 @@ class PaymentMethodService private $context; /** @var OrderTotalProviderInterface */ private $orderTotalProvider; - /** @var PaymentMethodLangService */ + /** @var PaymentMethodLangServiceInterface */ private $paymentMethodLangService; public function __construct( @@ -137,7 +137,7 @@ public function __construct( PaymentFeeProviderInterface $paymentFeeProvider, Context $context, OrderTotalProviderInterface $orderTotalProvider, - PaymentMethodLangService $paymentMethodLangService + PaymentMethodLangServiceInterface $paymentMethodLangService ) { $this->module = $module; $this->methodRepository = $methodRepository; diff --git a/src/ServiceProvider/BaseServiceProvider.php b/src/ServiceProvider/BaseServiceProvider.php index 96444b19b..76eb4cdbc 100644 --- a/src/ServiceProvider/BaseServiceProvider.php +++ b/src/ServiceProvider/BaseServiceProvider.php @@ -119,6 +119,8 @@ use Mollie\Service\PaymentMethod\PaymentMethodRestrictionValidationInterface; use Mollie\Service\PaymentMethod\PaymentMethodSortProvider; use Mollie\Service\PaymentMethod\PaymentMethodSortProviderInterface; +use Mollie\Service\PaymentMethodLangService; +use Mollie\Service\PaymentMethodLangServiceInterface; use Mollie\Service\Shipment\ShipmentInformationSender; use Mollie\Service\Shipment\ShipmentInformationSenderInterface; use Mollie\Service\ShipmentService; @@ -235,6 +237,8 @@ public function register(Container $container) $this->addService($container, CarrierRepositoryInterface::class, $container->get(CarrierRepository::class)); $this->addService($container, CartRuleQuantityChangeHandlerInterface::class, $container->get(CartRuleQuantityChangeHandler::class)); + $this->addService($container, PaymentMethodLangServiceInterface::class, $container->get(PaymentMethodLangService::class)); + $service = $this->addService($container, RecurringOrderRepositoryInterface::class, RecurringOrderRepository::class); $this->addServiceArgument($service, 'MolRecurringOrder');