-
Notifications
You must be signed in to change notification settings - Fork 44
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
GytisZum
merged 67 commits into
mollie:PIPRES-468/title-multilang
from
MarijusCoding:PIPRES-468/fork-title-multilang
Dec 10, 2024
Merged
Changes from 40 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 460aa45
comments deleted
GytisZum 398eb36
added todos to finish functionality
GytisZum e5003b1
[PIP-RES-468] closing string
MarijusCoding 1bd4f8f
[PIPRES-468] small fixes
MarijusCoding 6407595
[PIPRES-468] db
MarijusCoding 067cf83
[PIPRES-468] repo
MarijusCoding 3d695be
[PIPRES-468] object model
MarijusCoding dca8157
[PIPRES-468] wip
MarijusCoding d74d88d
[PIPRES-468] wip
MarijusCoding 8a33974
[PIPRES-468] typo
MarijusCoding 20c2a20
[PIPRES-468] wip
MarijusCoding 6fa8d36
[PIPRES-468] changed type
MarijusCoding f83eaa9
[PIPRES-468] edit table schema and rendering title
MarijusCoding d6b0451
[PIPRES-468] working MVP
MarijusCoding 690c460
[PIPRES-468] improvements
MarijusCoding 7348037
[PIPRES-468] improvements
MarijusCoding 87e531f
[PIPRES-468] update invertus contact address
MarijusCoding 1a50e17
[PIPRES-468] rendering titles by language logic
MarijusCoding 834f0a4
[PIPRES-468] typo return
MarijusCoding ac1d4df
[PIPRES-468] interface
MarijusCoding 0d318a1
[PIPRES-468] added interface and dependencies
MarijusCoding cb4e4eb
[PIPRES-468] use interface
MarijusCoding 90c620e
[PIPRES-468] add upgrade file
MarijusCoding b213c5b
[PIPRES-468] removed useless dependencies
MarijusCoding 203204b
[PIPRES-468] removed dependency
MarijusCoding d44e438
[PIPRES-468] comments on interface
MarijusCoding 937adb1
[PIPRES-468] fix
MarijusCoding 39f8740
[PIPRES-468] optimized and gived default EN title
MarijusCoding 978195c
[PIPRES-468] delete comments
MarijusCoding 61bc86d
[PIPRES-468] stable
MarijusCoding 745eecf
[PIPRES-468] stable
MarijusCoding 63516f8
[PIPRES-468] stable
MarijusCoding 6bcf548
[PIPRES-468] stable
MarijusCoding 86d1bc3
[PIPRES-468] stable
MarijusCoding 2ee9e0d
[PIPRES-468] stable
MarijusCoding 3c7482c
[PIPRES-468] changed method to get object
MarijusCoding 0f69450
[PIPRES-468] whitespace deletion
MarijusCoding 912a768
[PIPRES-468] Multishop compatibility fix
MarijusCoding ee70cc4
[PIPRES-468] fixed comments
MarijusCoding 1827b0a
[PIPRES-468] rename services
MarijusCoding 976a2f2
[PIPRES-468] removed useless translation service, removed title from …
MarijusCoding 056b7f6
[PIPRES-468] updated upgrade logic to add all titles into new table o…
MarijusCoding a40cb89
[PIPRES-468] bump version, fixed upgrade failing
MarijusCoding 518fe5d
[PIPRES-468] fix
MarijusCoding f4145ff
[PIPRES-468] renamed services
MarijusCoding 4ed282c
[PIPRES-468] renamed service to provider
MarijusCoding 5367ae4
[PIPRES-468] deleted service
MarijusCoding 7f85c3a
[PIPRES-468] renamed provider
MarijusCoding b70ecee
[PIPRES-468] removed table
MarijusCoding f113d60
[PIPRES-468] removed title from old database
MarijusCoding a097824
[PIPRES-468] rename lang to translation
MarijusCoding 01fc707
[PIPRES-468] optimized querys
MarijusCoding cb0b08b
[PIPRES-468] removed overengineered functions
MarijusCoding eb670fe
[PIPRES-468] removed provider
MarijusCoding ccb1d49
[PIPRES-468] removed privder
MarijusCoding 1488849
[PIPRES-468] remove dependency
MarijusCoding c630fd8
[PIPRES-468] whitespace
MarijusCoding d57a9c7
[PIPRES-468] removed useless altering
MarijusCoding 4cb2f2b
[PIPRES-468] added return type
MarijusCoding 81e1b6d
[PIPRES-468] add autoindex
MarijusCoding 7e6a927
[PIPRES-468] validation
MarijusCoding a1345fc
[PIPRES-468] added ps version checking
MarijusCoding e067c74
[PIPRES-468] fix typos
MarijusCoding c5cbb62
[PIPRES-468] fix name
MarijusCoding e9f923e
[PIPRES-468] shopContext -> context
MarijusCoding 19cdf48
[PIPRES-468] fix
MarijusCoding File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
], | ||
], | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,7 @@ | |
use Mollie\Provider\OrderTotal\OrderTotalProviderInterface; | ||
use Mollie\Provider\PaymentFeeProviderInterface; | ||
use Mollie\Service\LanguageService; | ||
use Mollie\Service\PaymentMethodLangService; | ||
use MolPaymentMethod; | ||
use PrestaShop\PrestaShop\Core\Payment\PaymentOption; | ||
use Tools; | ||
|
@@ -80,21 +81,25 @@ class BasePaymentOptionProvider implements PaymentOptionProviderInterface | |
private $languageService; | ||
/** @var OrderTotalProviderInterface */ | ||
private $orderTotalProvider; | ||
/** @var PaymentMethodLangService $multiLangService */ | ||
private $multiLangService; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. $paymentMethodLangProvider |
||
|
||
public function __construct( | ||
Mollie $module, | ||
LegacyContext $context, | ||
CreditCardLogoProvider $creditCardLogoProvider, | ||
PaymentFeeProviderInterface $paymentFeeProvider, | ||
LanguageService $languageService, | ||
OrderTotalProviderInterface $orderTotalProvider | ||
OrderTotalProviderInterface $orderTotalProvider, | ||
PaymentMethodLangService $multiLangService | ||
) { | ||
$this->module = $module; | ||
$this->context = $context; | ||
$this->creditCardLogoProvider = $creditCardLogoProvider; | ||
$this->paymentFeeProvider = $paymentFeeProvider; | ||
$this->languageService = $languageService; | ||
$this->orderTotalProvider = $orderTotalProvider; | ||
$this->multiLangService = $multiLangService; | ||
} | ||
|
||
/** | ||
|
@@ -105,9 +110,9 @@ public function getPaymentOption(MolPaymentMethod $paymentMethod): PaymentOption | |
$paymentOption = new PaymentOption(); | ||
|
||
$paymentOption->setCallToActionText( | ||
$paymentMethod->title ?: | ||
$this->languageService->lang($paymentMethod->method_name) | ||
$this->multiLangService->trans($paymentMethod->id_method) ?: $paymentMethod->title | ||
); | ||
|
||
$paymentOption->setModuleName($this->module->name); | ||
$paymentOption->setAction($this->context->getLink()->getModuleLink( | ||
'mollie', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?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\Repository; | ||
|
||
MarijusCoding marked this conversation as resolved.
Show resolved
Hide resolved
|
||
use Mollie\Shared\Infrastructure\Repository\AbstractRepository; | ||
|
||
if (!defined('_PS_VERSION_')) { | ||
exit; | ||
} | ||
|
||
class MultiLangRepository extends AbstractRepository implements MultiLangRepositoryInterface | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MolPaymentMethodLangRepository |
||
{ | ||
public function __construct() | ||
{ | ||
parent::__construct(\MolPaymentMethodLang::class); | ||
} | ||
|
||
public function getTextByLanguageAndMethod(int $idLanguage, string $idMethod, int $idShop): ?string | ||
{ | ||
$sql = new \DbQuery(); | ||
$sql->select('`text`'); | ||
$sql->from('mol_payment_method_lang'); | ||
$sql->where('`id_method` = "' . pSQL($idMethod) . '"'); | ||
$sql->where('`id_lang` = ' . $idLanguage); | ||
$sql->where('`id_shop` = ' . $idShop); | ||
|
||
return \Db::getInstance()->getValue($sql) ?: null; | ||
} | ||
|
||
public function getAllTranslationsByMethod(string $idPaymentMethod, int $idShop): array | ||
{ | ||
$sql = new \DbQuery(); | ||
$sql->select('`id_lang`, `text`'); | ||
$sql->from('mol_payment_method_lang'); | ||
$sql->where('`id_method` = "' . pSQL($idPaymentMethod) . '"'); | ||
$sql->where('`id_shop` = ' . $idShop); | ||
|
||
return \Db::getInstance()->executeS($sql) ?? []; | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider removing this title from the payment method table. Implement upgrade method to write this title into your table if this one exist