diff --git a/core/lib/Thelia/Core/Template/Loop/Content.php b/core/lib/Thelia/Core/Template/Loop/Content.php index df0f18aff..5a24377fa 100644 --- a/core/lib/Thelia/Core/Template/Loop/Content.php +++ b/core/lib/Thelia/Core/Template/Loop/Content.php @@ -60,7 +60,20 @@ class Content extends BaseI18nLoop implements PropelSearchLoopInterface new Argument( 'order', new TypeCollection( - new Type\EnumListType(array('alpha', 'alpha-reverse', 'manual', 'manual_reverse', 'random', 'given_id', 'created', 'created_reverse', 'updated', 'updated_reverse')) + new Type\EnumListType( + array( + 'alpha', + 'alpha-reverse', + 'manual', + 'manual_reverse', + 'random', + 'given_id', + 'created', + 'created_reverse', + 'updated', + 'updated_reverse' + ) + ) ), 'alpha' ), diff --git a/core/lib/Thelia/Form/OrderDelivery.php b/core/lib/Thelia/Form/OrderDelivery.php index 74ad75f33..47d8bdfa8 100644 --- a/core/lib/Thelia/Form/OrderDelivery.php +++ b/core/lib/Thelia/Form/OrderDelivery.php @@ -66,19 +66,15 @@ class OrderDelivery extends BaseForm public function verifyDeliveryModule($value, ExecutionContextInterface $context) { $module = ModuleQuery::create() - ->filterByType(BaseModule::DELIVERY_MODULE_TYPE) - ->filterByActivate(1) - ->filterById($value) + ->filterActivatedByTypeAndId(BaseModule::DELIVERY_MODULE_TYPE, $value) ->findOne(); if (null === $module) { $context->addViolation(Translator::getInstance()->trans("Delivery module ID not found")); - } else { - if (! $module->isDeliveryModule()) { - $context->addViolation( - sprintf(Translator::getInstance()->trans("delivery module %s is not a Thelia\Module\DeliveryModuleInterface"), $module->getCode()) - ); - } + } elseif (! $module->isDeliveryModule()) { + $context->addViolation( + sprintf(Translator::getInstance()->trans("delivery module %s is not a Thelia\Module\DeliveryModuleInterface"), $module->getCode()) + ); } } diff --git a/core/lib/Thelia/Form/OrderPayment.php b/core/lib/Thelia/Form/OrderPayment.php index 9353eee37..6d1182a4a 100644 --- a/core/lib/Thelia/Form/OrderPayment.php +++ b/core/lib/Thelia/Form/OrderPayment.php @@ -66,16 +66,12 @@ class OrderPayment extends BaseForm public function verifyPaymentModule($value, ExecutionContextInterface $context) { $module = ModuleQuery::create() - ->filterByType(BaseModule::PAYMENT_MODULE_TYPE) - ->filterByActivate(1) - ->filterById($value) + ->filterActivatedByTypeAndId(BaseModule::PAYMENT_MODULE_TYPE, $value) ->findOne(); if (null === $module) { $context->addViolation("Payment module ID not found"); - } - - if (! $module->isPayementModule()) { + } elseif (! $module->isPayementModule()) { $context->addViolation( sprintf(Translator::getInstance()->trans("payment module %s is not a Thelia\Module\PaymentModuleInterface"), $module->getCode()) ); diff --git a/core/lib/Thelia/Model/ModuleQuery.php b/core/lib/Thelia/Model/ModuleQuery.php index c1f9394dd..90a3dc8c2 100644 --- a/core/lib/Thelia/Model/ModuleQuery.php +++ b/core/lib/Thelia/Model/ModuleQuery.php @@ -3,6 +3,7 @@ namespace Thelia\Model; use Thelia\Model\Base\ModuleQuery as BaseModuleQuery; +use Thelia\Module\BaseModule; /** * Skeleton subclass for performing query and update operations on the 'module' table. @@ -24,7 +25,7 @@ class ModuleQuery extends BaseModuleQuery { if (null === self::$activated) { self::$activated = self::create() - ->filterByActivate(1) + ->filterByActivate(BaseModule::IS_ACTIVATED) ->orderByPosition() ->find(); } @@ -37,4 +38,17 @@ class ModuleQuery extends BaseModuleQuery self::$activated = null; } + /** + * @param int $moduleType the module type : classic, payment or delivery. Use BaseModule constant here. + * @param int $id the module id + * @return ModuleQuery + */ + public function filterActivatedByTypeAndId($moduleType, $id) + { + return $this + ->filterByType($moduleType) + ->filterByActivate(BaseModule::IS_ACTIVATED) + ->filterById($id); + } + } // ModuleQuery