Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PIPRES-468 "Title" multilanguage functionality #997

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
dc0311f
PIPRES-468: frontend implementation by reusing prestashop multilang form
GytisZum Nov 12, 2024
460aa45
comments deleted
GytisZum Nov 12, 2024
398eb36
added todos to finish functionality
GytisZum Nov 12, 2024
e5003b1
[PIP-RES-468] closing string
MarijusCoding Nov 19, 2024
1bd4f8f
[PIPRES-468] small fixes
MarijusCoding Nov 19, 2024
6407595
[PIPRES-468] db
MarijusCoding Nov 19, 2024
067cf83
[PIPRES-468] repo
MarijusCoding Nov 19, 2024
3d695be
[PIPRES-468] object model
MarijusCoding Nov 19, 2024
dca8157
[PIPRES-468] wip
MarijusCoding Nov 19, 2024
d74d88d
[PIPRES-468] wip
MarijusCoding Nov 19, 2024
8a33974
[PIPRES-468] typo
MarijusCoding Nov 19, 2024
20c2a20
[PIPRES-468] wip
MarijusCoding Nov 20, 2024
6fa8d36
[PIPRES-468] changed type
MarijusCoding Nov 20, 2024
f83eaa9
[PIPRES-468] edit table schema and rendering title
MarijusCoding Nov 20, 2024
d6b0451
[PIPRES-468] working MVP
MarijusCoding Nov 20, 2024
690c460
[PIPRES-468] improvements
MarijusCoding Nov 20, 2024
7348037
[PIPRES-468] improvements
MarijusCoding Nov 20, 2024
87e531f
[PIPRES-468] update invertus contact address
MarijusCoding Nov 20, 2024
1a50e17
[PIPRES-468] rendering titles by language logic
MarijusCoding Nov 20, 2024
834f0a4
[PIPRES-468] typo return
MarijusCoding Nov 20, 2024
ac1d4df
[PIPRES-468] interface
MarijusCoding Nov 20, 2024
0d318a1
[PIPRES-468] added interface and dependencies
MarijusCoding Nov 20, 2024
cb4e4eb
[PIPRES-468] use interface
MarijusCoding Nov 20, 2024
90c620e
[PIPRES-468] add upgrade file
MarijusCoding Nov 20, 2024
b213c5b
[PIPRES-468] removed useless dependencies
MarijusCoding Nov 20, 2024
203204b
[PIPRES-468] removed dependency
MarijusCoding Nov 20, 2024
d44e438
[PIPRES-468] comments on interface
MarijusCoding Nov 20, 2024
937adb1
[PIPRES-468] fix
MarijusCoding Nov 20, 2024
39f8740
[PIPRES-468] optimized and gived default EN title
MarijusCoding Nov 20, 2024
978195c
[PIPRES-468] delete comments
MarijusCoding Nov 20, 2024
61bc86d
[PIPRES-468] stable
MarijusCoding Nov 20, 2024
745eecf
[PIPRES-468] stable
MarijusCoding Nov 20, 2024
63516f8
[PIPRES-468] stable
MarijusCoding Nov 20, 2024
6bcf548
[PIPRES-468] stable
MarijusCoding Nov 20, 2024
86d1bc3
[PIPRES-468] stable
MarijusCoding Nov 20, 2024
2ee9e0d
[PIPRES-468] stable
MarijusCoding Nov 20, 2024
3c7482c
[PIPRES-468] changed method to get object
MarijusCoding Nov 20, 2024
0f69450
[PIPRES-468] whitespace deletion
MarijusCoding Nov 20, 2024
912a768
[PIPRES-468] Multishop compatibility fix
MarijusCoding Nov 21, 2024
ee70cc4
[PIPRES-468] fixed comments
MarijusCoding Nov 21, 2024
1827b0a
[PIPRES-468] rename services
MarijusCoding Nov 25, 2024
976a2f2
[PIPRES-468] removed useless translation service, removed title from …
MarijusCoding Nov 25, 2024
056b7f6
[PIPRES-468] updated upgrade logic to add all titles into new table o…
MarijusCoding Nov 25, 2024
a40cb89
[PIPRES-468] bump version, fixed upgrade failing
MarijusCoding Nov 25, 2024
518fe5d
[PIPRES-468] fix
MarijusCoding Nov 25, 2024
f4145ff
[PIPRES-468] renamed services
MarijusCoding Nov 25, 2024
4ed282c
[PIPRES-468] renamed service to provider
MarijusCoding Nov 26, 2024
5367ae4
[PIPRES-468] deleted service
MarijusCoding Nov 26, 2024
7f85c3a
[PIPRES-468] renamed provider
MarijusCoding Nov 26, 2024
b70ecee
[PIPRES-468] removed table
MarijusCoding Nov 26, 2024
f113d60
[PIPRES-468] removed title from old database
MarijusCoding Nov 26, 2024
a097824
[PIPRES-468] rename lang to translation
MarijusCoding Nov 26, 2024
01fc707
[PIPRES-468] optimized querys
MarijusCoding Nov 26, 2024
cb0b08b
[PIPRES-468] removed overengineered functions
MarijusCoding Nov 26, 2024
eb670fe
[PIPRES-468] removed provider
MarijusCoding Nov 26, 2024
ccb1d49
[PIPRES-468] removed privder
MarijusCoding Nov 26, 2024
1488849
[PIPRES-468] remove dependency
MarijusCoding Nov 26, 2024
c630fd8
[PIPRES-468] whitespace
MarijusCoding Nov 26, 2024
d57a9c7
[PIPRES-468] removed useless altering
MarijusCoding Nov 26, 2024
4cb2f2b
[PIPRES-468] added return type
MarijusCoding Nov 26, 2024
81e1b6d
[PIPRES-468] add autoindex
MarijusCoding Nov 26, 2024
7e6a927
[PIPRES-468] validation
MarijusCoding Nov 26, 2024
a1345fc
[PIPRES-468] added ps version checking
MarijusCoding Nov 26, 2024
e067c74
[PIPRES-468] fix typos
MarijusCoding Nov 26, 2024
c5cbb62
[PIPRES-468] fix name
MarijusCoding Nov 27, 2024
e9f923e
[PIPRES-468] shopContext -> context
MarijusCoding Nov 27, 2024
19cdf48
[PIPRES-468] fix
MarijusCoding Dec 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mollie.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function __construct()
{
$this->name = 'mollie';
$this->tab = 'payments_gateways';
$this->version = '6.2.4';
$this->version = '6.2.5';
$this->author = 'Mollie B.V.';
$this->need_instance = 1;
$this->bootstrap = true;
Expand Down
11 changes: 11 additions & 0 deletions shared/Core/Shared/Repository/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');

header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');

header('Location: ../');
exit;
4 changes: 4 additions & 0 deletions shared/Infrastructure/Exception/MollieDatabaseException.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
use Mollie\Exception\Code\ExceptionCode;
use Mollie\Exception\MollieException;

if (!defined('_PS_VERSION_')) {
exit;
}

class MollieDatabaseException extends MollieException
{
public static function failedToFindRecord(string $className, array $keyValues): self
Expand Down
6 changes: 0 additions & 6 deletions src/Entity/MolPaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ class MolPaymentMethod extends ObjectModel
*/
public $method_name;

/**
* @var string
*/
public $title;

/**
* @var string
*/
Expand Down Expand Up @@ -123,7 +118,6 @@ class MolPaymentMethod extends ObjectModel
'id_method' => ['type' => self::TYPE_STRING, 'validate' => 'isString'],
'method_name' => ['type' => self::TYPE_STRING, 'validate' => 'isString'],
'enabled' => ['type' => self::TYPE_BOOL, 'validate' => 'isBool'],
'title' => ['type' => self::TYPE_STRING, 'validate' => 'isString'],
'method' => ['type' => self::TYPE_STRING, 'validate' => 'isString'],
'description' => ['type' => self::TYPE_STRING, 'validate' => 'isString'],
'is_countries_applicable' => ['type' => self::TYPE_BOOL, 'validate' => 'isBool'],
Expand Down
66 changes: 66 additions & 0 deletions src/Entity/MolPaymentMethodLang.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?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
*/

if (!defined('_PS_VERSION_')) {
exit;
}

class MolPaymentMethodLang extends ObjectModel
{
/** @var int */
public $id;

/** @var string name of the payment method */
public $id_method;

/** @var int */
public $id_lang;

/** @var int */
public $id_shop;

/** @var string payment title */
public $text;

/**
* Definition of the ObjectModel
*/
public static $definition = [
'table' => 'mol_payment_method_lang',
'primary' => 'id',
'fields' => [
'id_method' => [
'type' => self::TYPE_STRING,
'validate' => 'isString',
'required' => true,
MarijusCoding marked this conversation as resolved.
Show resolved Hide resolved
'size' => 64,
],
'id_lang' => [
'type' => self::TYPE_INT,
'validate' => 'isUnsignedInt',
'required' => true,
'size' => 11,
],
'id_shop' => [
'type' => self::TYPE_INT,
'validate' => 'isUnsignedInt',
'required' => true,
'size' => 11,
],
'text' => [
'type' => self::TYPE_STRING,
'validate' => 'isString',
'size' => 255,
],
],
];
}
11 changes: 10 additions & 1 deletion src/Install/DatabaseTableInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ private function getCommands()
`id_method` VARCHAR(64) NOT NULL,
`method_name` VARCHAR(64) NOT NULL,
`enabled` TINYINT(1),
`title` VARCHAR(64),
`method` VARCHAR(64),
`description` VARCHAR(255),
`is_countries_applicable` TINYINT(1),
Expand Down Expand Up @@ -151,6 +150,16 @@ private function getCommands()
INDEX (`id_shop`)
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8;';

$sql[] = '
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'mol_payment_method_lang` (
`id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`id_method` VARCHAR(64) NOT NULL,
`id_lang` INT(11),
`id_shop` INT(11),
`text` TINYTEXT,
INDEX (`id_method`)
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8;';

return $sql;
}

Expand Down
1 change: 1 addition & 0 deletions src/Install/DatabaseTableUninstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ private function getCommands(): array
$sql[] = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'mol_excluded_country`;';
$sql[] = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'mol_pending_order_cart_rule`;';
$sql[] = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'mol_payment_method_order_total_restriction`;';
$sql[] = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'mol_payment_method_lang`;';

return $sql;
}
Expand Down
4 changes: 4 additions & 0 deletions src/Logger/LogFormatterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

namespace Mollie\Logger;

if (!defined('_PS_VERSION_')) {
exit;
}

interface LogFormatterInterface
{
/**
Expand Down
4 changes: 4 additions & 0 deletions src/Logger/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
use Mollie\Service\EntityManager\ObjectModelUnitOfWork;
use Mollie\Utility\NumberIdempotencyProvider;

if (!defined('_PS_VERSION_')) {
exit;
}

class Logger implements LoggerInterface
{
public const FILE_NAME = 'Logger';
Expand Down
4 changes: 4 additions & 0 deletions src/Logger/LoggerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

namespace Mollie\Logger;

if (!defined('_PS_VERSION_')) {
exit;
}

interface LoggerInterface extends \Psr\Log\LoggerInterface
{
}
19 changes: 17 additions & 2 deletions src/Provider/PaymentOption/BancontactPaymentOptionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@
namespace Mollie\Provider\PaymentOption;

use Mollie;
use Mollie\Adapter\Context;
use Mollie\Adapter\LegacyContext;
use Mollie\Api\Types\PaymentMethod;
use Mollie\Provider\CreditCardLogoProvider;
use Mollie\Provider\OrderTotal\OrderTotalProviderInterface;
use Mollie\Provider\PaymentFeeProviderInterface;
use Mollie\Repository\PaymentMethodLangRepositoryInterface;
use Mollie\Service\LanguageService;
use MolPaymentMethod;
use PrestaShop\PrestaShop\Core\Payment\PaymentOption;
Expand Down Expand Up @@ -79,6 +81,7 @@ class BancontactPaymentOptionProvider implements PaymentOptionProviderInterface
* @var LanguageService
*/
private $languageService;

/** @var OrderTotalProviderInterface */
private $orderTotalProvider;

Expand All @@ -105,10 +108,22 @@ public function getPaymentOption(MolPaymentMethod $paymentMethod): PaymentOption
{
$paymentOption = new PaymentOption();

/** @var Context $context */
$context = $this->module->getService(Context::class);

/** @var PaymentMethodLangRepositoryInterface $paymentMethodLangRepository */
$paymentMethodLangRepository = $this->module->getService(PaymentMethodLangRepositoryInterface::class);

$paymentMethodLangObject = $paymentMethodLangRepository->findOneBy([
'id_method' => $paymentMethod->id_method,
'id_lang' => $context->getLanguageId(),
'id_shop' => $context->getShopId(),
]);

$paymentOption->setCallToActionText(
$paymentMethod->title ?:
$this->languageService->lang($paymentMethod->method_name)
$paymentMethodLangObject->text ?: $paymentMethod->method_name
);

$paymentOption->setModuleName($this->module->name);
$paymentOption->setAction($this->context->getLink()->getModuleLink(
'mollie',
Expand Down
19 changes: 17 additions & 2 deletions src/Provider/PaymentOption/BasePaymentOptionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@
namespace Mollie\Provider\PaymentOption;

use Mollie;
use Mollie\Adapter\Context;
use Mollie\Adapter\LegacyContext;
use Mollie\Provider\CreditCardLogoProvider;
use Mollie\Provider\OrderTotal\OrderTotalProviderInterface;
use Mollie\Provider\PaymentFeeProviderInterface;
use Mollie\Repository\PaymentMethodLangRepositoryInterface;
use Mollie\Service\LanguageService;
use MolPaymentMethod;
use PrestaShop\PrestaShop\Core\Payment\PaymentOption;
Expand Down Expand Up @@ -78,6 +80,7 @@ class BasePaymentOptionProvider implements PaymentOptionProviderInterface
* @var LanguageService
*/
private $languageService;

/** @var OrderTotalProviderInterface */
private $orderTotalProvider;

Expand All @@ -104,10 +107,22 @@ public function getPaymentOption(MolPaymentMethod $paymentMethod): PaymentOption
{
$paymentOption = new PaymentOption();

/** @var Context $context */
$context = $this->module->getService(Context::class);

/** @var PaymentMethodLangRepositoryInterface $paymentMethodLangRepository */
$paymentMethodLangRepository = $this->module->getService(PaymentMethodLangRepositoryInterface::class);

$paymentMethodLangObject = $paymentMethodLangRepository->findOneBy([
'id_method' => $paymentMethod->id_method,
'id_lang' => $context->getLanguageId(),
'id_shop' => $context->getShopId(),
]);

$paymentOption->setCallToActionText(
$paymentMethod->title ?:
$this->languageService->lang($paymentMethod->method_name)
$paymentMethodLangObject->text ?: $paymentMethod->method_name
);

$paymentOption->setModuleName($this->module->name);
$paymentOption->setAction($this->context->getLink()->getModuleLink(
'mollie',
Expand Down
19 changes: 17 additions & 2 deletions src/Provider/PaymentOption/CreditCardPaymentOptionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@
use MolCustomer;
use Mollie;
use Mollie\Adapter\ConfigurationAdapter;
use Mollie\Adapter\Context;
use Mollie\Adapter\Customer;
use Mollie\Adapter\LegacyContext;
use Mollie\Config\Config;
use Mollie\Provider\CreditCardLogoProvider;
use Mollie\Provider\OrderTotal\OrderTotalProviderInterface;
use Mollie\Provider\PaymentFeeProviderInterface;
use Mollie\Repository\MolCustomerRepository;
use Mollie\Repository\PaymentMethodLangRepositoryInterface;
use Mollie\Service\LanguageService;
use Mollie\Utility\CustomerUtility;
use MolPaymentMethod;
Expand Down Expand Up @@ -128,10 +130,23 @@ public function __construct(
public function getPaymentOption(MolPaymentMethod $paymentMethod): PaymentOption
{
$paymentOption = new PaymentOption();

/** @var Context $context */
$context = $this->module->getService(Context::class);

/** @var PaymentMethodLangRepositoryInterface $paymentMethodLangRepository */
$paymentMethodLangRepository = $this->module->getService(PaymentMethodLangRepositoryInterface::class);

$paymentMethodLangObject = $paymentMethodLangRepository->findOneBy([
'id_method' => $paymentMethod->id_method,
'id_lang' => $context->getLanguageId(),
'id_shop' => $context->getShopId(),
]);

$paymentOption->setCallToActionText(
$paymentMethod->title ?:
$this->languageService->lang($paymentMethod->method_name)
$paymentMethodLangObject->text ?: $paymentMethod->method_name
);

$paymentOption->setModuleName($this->module->name);
$paymentOption->setAction($this->context->getLink()->getModuleLink(
'mollie',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@
use MolCustomer;
use Mollie;
use Mollie\Adapter\ConfigurationAdapter;
use Mollie\Adapter\Context;
use Mollie\Adapter\LegacyContext;
use Mollie\Config\Config;
use Mollie\Provider\CreditCardLogoProvider;
use Mollie\Provider\OrderTotal\OrderTotalProviderInterface;
use Mollie\Provider\PaymentFeeProviderInterface;
use Mollie\Repository\MolCustomerRepository;
use Mollie\Repository\PaymentMethodLangRepositoryInterface;
use Mollie\Service\LanguageService;
use Mollie\Utility\CustomerUtility;
use MolPaymentMethod;
Expand Down Expand Up @@ -126,10 +128,22 @@ public function getPaymentOption(MolPaymentMethod $paymentMethod): PaymentOption
{
$paymentOption = new PaymentOption();

/** @var Context $context */
$context = $this->module->getService(Context::class);

/** @var PaymentMethodLangRepositoryInterface $paymentMethodLangRepository */
$paymentMethodLangRepository = $this->module->getService(PaymentMethodLangRepositoryInterface::class);

$paymentMethodLangObject = $paymentMethodLangRepository->findOneBy([
'id_method' => $paymentMethod->id_method,
'id_lang' => $context->getLanguageId(),
'id_shop' => $context->getShopId(),
]);

$paymentOption->setCallToActionText(
$paymentMethod->title ?:
$this->languageService->lang($paymentMethod->method_name)
$paymentMethodLangObject->text ?: $paymentMethod->method_name
);

$paymentOption->setModuleName($this->module->name);
$paymentOption->setAction($this->context->getLink()->getModuleLink(
'mollie',
Expand Down
18 changes: 16 additions & 2 deletions src/Provider/PaymentOption/IdealPaymentOptionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@
namespace Mollie\Provider\PaymentOption;

use Mollie;
use Mollie\Adapter\Context;
use Mollie\Adapter\LegacyContext;
use Mollie\Provider\CreditCardLogoProvider;
use Mollie\Provider\OrderTotal\OrderTotalProviderInterface;
use Mollie\Provider\PaymentFeeProviderInterface;
use Mollie\Repository\PaymentMethodLangRepositoryInterface;
use Mollie\Service\Content\TemplateParserInterface;
use Mollie\Service\LanguageService;
use MolPaymentMethod;
Expand Down Expand Up @@ -112,10 +114,22 @@ public function getPaymentOption(MolPaymentMethod $paymentMethod): PaymentOption
{
$paymentOption = new PaymentOption();

/** @var Context $context */
$context = $this->module->getService(Context::class);

/** @var PaymentMethodLangRepositoryInterface $paymentMethodLangRepository */
$paymentMethodLangRepository = $this->module->getService(PaymentMethodLangRepositoryInterface::class);

$paymentMethodLangObject = $paymentMethodLangRepository->findOneBy([
'id_method' => $paymentMethod->id_method,
'id_lang' => $context->getLanguageId(),
'id_shop' => $context->getShopId(),
]);

$paymentOption->setCallToActionText(
$paymentMethod->title ?:
$this->languageService->lang($paymentMethod->method_name)
$paymentMethodLangObject->text ?: $paymentMethod->method_name
);

$paymentOption->setModuleName($this->module->name);
$paymentOption->setAction($this->context->getLink()->getModuleLink(
'mollie',
Expand Down
Loading
Loading