tax rule set default in back office

This commit is contained in:
Etienne Roudeix
2013-10-17 15:31:09 +02:00
parent dad2591a57
commit dc2de702e8
6 changed files with 97 additions and 18 deletions

View File

@@ -27,6 +27,7 @@ use Propel\Runtime\ActiveQuery\Criteria;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\Tax\TaxRuleEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Model\Map\TaxRuleTableMap;
use Thelia\Model\TaxRuleCountry;
use Thelia\Model\TaxRuleCountryQuery;
use Thelia\Model\TaxRule as TaxRuleModel;
@@ -134,6 +135,23 @@ class TaxRule extends BaseAction implements EventSubscriberInterface
}
}
/**
* @param TaxRuleEvent $event
*/
public function setDefault(TaxRuleEvent $event)
{
if (null !== $taxRule = TaxRuleQuery::create()->findPk($event->getId())) {
TaxRuleQuery::create()->update(array(
"IsDefault" => 0
));
$taxRule->setIsDefault(1)->save();
$event->setTaxRule($taxRule);
}
}
/**
* {@inheritDoc}
*/
@@ -144,7 +162,7 @@ class TaxRule extends BaseAction implements EventSubscriberInterface
TheliaEvents::TAX_RULE_UPDATE => array("update", 128),
TheliaEvents::TAX_RULE_TAXES_UPDATE => array("updateTaxes", 128),
TheliaEvents::TAX_RULE_DELETE => array("delete", 128),
TheliaEvents::TAX_RULE_SET_DEFAULT => array("setDefault", 128),
);
}
}