From 25084219e740416d0ce133c04327faf25249ae4c Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Sat, 8 Feb 2014 11:07:54 +0100 Subject: [PATCH] create new method in PaymentModuleInterface for verifying is the module is valid --- core/lib/Thelia/Core/Template/Loop/Payment.php | 4 ++++ core/lib/Thelia/Module/PaymentModuleInterface.php | 11 +++++++++++ local/modules/Cheque/Cheque.php | 14 ++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/core/lib/Thelia/Core/Template/Loop/Payment.php b/core/lib/Thelia/Core/Template/Loop/Payment.php index dee4f176a..20a387e0e 100644 --- a/core/lib/Thelia/Core/Template/Loop/Payment.php +++ b/core/lib/Thelia/Core/Template/Loop/Payment.php @@ -54,6 +54,10 @@ class Payment extends BaseSpecificModule implements PropelSearchLoopInterface throw new \RuntimeException(sprintf("payment module %s is not a Thelia\Module\PaymentModuleInterface", $paymentModule->getCode())); } + if (false === $moduleInstance->isValidPayment()) { + continue; + } + $loopResultRow ->set('ID', $paymentModule->getId()) ->set('TITLE', $paymentModule->getVirtualColumn('i18n_TITLE')) diff --git a/core/lib/Thelia/Module/PaymentModuleInterface.php b/core/lib/Thelia/Module/PaymentModuleInterface.php index 00f3db0dd..fd3283e3f 100644 --- a/core/lib/Thelia/Module/PaymentModuleInterface.php +++ b/core/lib/Thelia/Module/PaymentModuleInterface.php @@ -31,4 +31,15 @@ interface PaymentModuleInterface extends BaseModuleInterface * @return mixed */ public function pay(Order $order); + + /** + * + * This method is call on Payment loop. + * + * If you return true, the payment method will de display + * If you return false, the payment method will not be display + * + * @return boolean + */ + public function isValidPayment(); } diff --git a/local/modules/Cheque/Cheque.php b/local/modules/Cheque/Cheque.php index b7a22a8ef..05cac75aa 100644 --- a/local/modules/Cheque/Cheque.php +++ b/local/modules/Cheque/Cheque.php @@ -61,6 +61,20 @@ class Cheque extends BaseModule implements PaymentModuleInterface // no special process, waiting for the cheque. } + /** + * + * This method is call on Payment loop. + * + * If you return true, the payment method will de display + * If you return false, the payment method will not be display + * + * @return boolean + */ + public function isValidPayment() + { + return true; + } + public function postActivation(ConnectionInterface $con = null) {