Working : Coupon : fix links and errors display

This commit is contained in:
gmorel
2013-09-13 12:42:33 +02:00
parent 530c3d1102
commit ed4809bac4
14 changed files with 411 additions and 397 deletions

View File

@@ -24,6 +24,7 @@
namespace Thelia\Core\Template\Loop;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\Util\PropelModelPager;
use Thelia\Constraint\ConstraintFactory;
use Thelia\Constraint\Rule\CouponRuleInterface;
use Thelia\Core\HttpFoundation\Request;
@@ -38,6 +39,7 @@ use Thelia\Coupon\Type\CouponInterface;
use Thelia\Model\CouponQuery;
use Thelia\Model\Coupon as MCoupon;
use Thelia\Type;
use Thelia\Type\BooleanOrBothType;
/**
* Created by JetBrains PhpStorm.
@@ -53,17 +55,22 @@ use Thelia\Type;
class Coupon extends BaseI18nLoop
{
/**
* Define all args used in your loop
*
* @return ArgumentCollection
*/
protected function getArgDefinitions()
{
return new ArgumentCollection(
Argument::createIntListTypeArgument('id')
Argument::createIntListTypeArgument('id'),
Argument::createBooleanOrBothTypeArgument('is_enabled', 1)
);
}
/**
* @param $pagination
* Execute Loop
*
* @param PropelModelPager $pagination
*
* @return \Thelia\Core\Template\Element\LoopResult
*/
@@ -75,11 +82,16 @@ class Coupon extends BaseI18nLoop
$locale = $this->configureI18nProcessing($search, array('TITLE', 'DESCRIPTION', 'SHORT_DESCRIPTION'));
$id = $this->getId();
$isEnabled = $this->getIsEnabled();
if (null !== $id) {
$search->filterById($id, Criteria::IN);
}
if ($isEnabled != BooleanOrBothType::ANY) {
$search->filterByIsEnabled($isEnabled ? 1 : 0);
}
// Perform search
$coupons = $this->search($search, $pagination);
@@ -122,7 +134,7 @@ class Coupon extends BaseI18nLoop
$cleanedRules = array();
/** @var CouponRuleInterface $rule */
foreach ($rules->getRules() as $key => $rule) {
foreach ($rules->getRules() as $rule) {
$cleanedRules[] = $rule->getToolTip();
}
$loopResultRow->set("ID", $coupon->getId())