Skip to content

Commit

Permalink
[PIPRES-468] moved to interface
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijusCoding committed Nov 20, 2024
1 parent 978195c commit f1ebcda
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -83,7 +83,7 @@ class BancontactPaymentOptionProvider implements PaymentOptionProviderInterface
/** @var OrderTotalProviderInterface */
private $orderTotalProvider;

/** @var PaymentMethodLangService $multiLangService */
/** @var PaymentMethodLangServiceInterface $multiLangService */
private $multiLangService;

public function __construct(
Expand All @@ -93,7 +93,7 @@ public function __construct(
PaymentFeeProviderInterface $paymentFeeProvider,
LanguageService $languageService,
OrderTotalProviderInterface $orderTotalProvider,
PaymentMethodLangService $multiLangService
PaymentMethodLangServiceInterface $multiLangService
) {
$this->module = $module;
$this->context = $context;
Expand Down
6 changes: 3 additions & 3 deletions src/Provider/PaymentOption/BasePaymentOptionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand All @@ -91,7 +91,7 @@ public function __construct(
PaymentFeeProviderInterface $paymentFeeProvider,
LanguageService $languageService,
OrderTotalProviderInterface $orderTotalProvider,
PaymentMethodLangService $multiLangService
PaymentMethodLangServiceInterface $multiLangService
) {
$this->module = $module;
$this->context = $context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/Provider/PaymentOption/IdealPaymentOptionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -98,7 +98,7 @@ public function __construct(
TemplateParserInterface $templateParser,
LanguageService $languageService,
OrderTotalProviderInterface $orderTotalProvider,
PaymentMethodLangService $multiLangService
PaymentMethodLangServiceInterface $multiLangService
) {
$this->module = $module;
$this->context = $context;
Expand Down
4 changes: 2 additions & 2 deletions src/Service/ApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class ApiService implements ApiServiceInterface
private $taxProvider;
/** @var Context */
private $context;
/** @var PaymentMethodLangService */
/** @var PaymentMethodLangServiceInterface */
private $multiLangService;

public function __construct(
Expand All @@ -93,7 +93,7 @@ public function __construct(
Shop $shop,
TaxCalculatorProvider $taxProvider,
Context $context,
PaymentMethodLangService $multiLangService
PaymentMethodLangServiceInterface $multiLangService
) {
$this->countryRepository = $countryRepository;
$this->paymentMethodSortProvider = $paymentMethodSortProvider;
Expand Down
9 changes: 1 addition & 8 deletions src/Service/PaymentMethodLangService.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
exit;
}

class PaymentMethodLangService
class PaymentMethodLangService implements PaymentMethodLangServiceInterface
{
/** @var MultiLangRepositoryInterface */
private $multiLangRepository;
Expand Down Expand Up @@ -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());
Expand Down
38 changes: 38 additions & 0 deletions src/Service/PaymentMethodLangServiceInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
/**
* Mollie https://www.mollie.nl
*
* @author Mollie B.V. <[email protected]>
* @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;
}
4 changes: 2 additions & 2 deletions src/Service/PaymentMethodService.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class PaymentMethodService
private $context;
/** @var OrderTotalProviderInterface */
private $orderTotalProvider;
/** @var PaymentMethodLangService */
/** @var PaymentMethodLangServiceInterface */
private $paymentMethodLangService;

public function __construct(
Expand All @@ -137,7 +137,7 @@ public function __construct(
PaymentFeeProviderInterface $paymentFeeProvider,
Context $context,
OrderTotalProviderInterface $orderTotalProvider,
PaymentMethodLangService $paymentMethodLangService
PaymentMethodLangServiceInterface $paymentMethodLangService
) {
$this->module = $module;
$this->methodRepository = $methodRepository;
Expand Down
4 changes: 4 additions & 0 deletions src/ServiceProvider/BaseServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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');

Expand Down

0 comments on commit f1ebcda

Please sign in to comment.