enabled change default country

This commit is contained in:
Manuel Raynaud
2013-10-08 10:16:18 +02:00
parent d45074051e
commit 43467681fd
9 changed files with 107 additions and 8 deletions

View File

@@ -11,6 +11,17 @@ class Country extends BaseCountry
{
use \Thelia\Model\Tools\ModelEventDispatcherTrait;
public function toggleDefault()
{
CountryQuery::create()
->filterByByDefault(1)
->update(array('ByDefault' => 0));
$this
->setByDefault(1)
->save();
}
public function preInsert(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::BEFORE_CREATECOUNTRY, new CountryEvent($this));