dispatch event when default currency change

This commit is contained in:
Manuel Raynaud
2013-09-16 09:07:53 +02:00
parent 6120d4e69d
commit a4c8df366b
2 changed files with 7 additions and 0 deletions

View File

@@ -367,6 +367,8 @@ final class TheliaEvents
const BEFORE_DELETECURRENCY = "action.before_deleteCurrency";
const AFTER_DELETECURRENCY = "action.after_deleteCurrency";
const CHANGE_DEFAULT_CURRENCY = 'action.changeDefaultCurrency';
// -- Attributes management ---------------------------------------------
const ATTRIBUTE_CREATE = "action.createAttribute";

View File

@@ -32,6 +32,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Session;
use Thelia\Core\Event\CurrencyEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Model;
/**
@@ -146,6 +148,9 @@ class TheliaHttpKernel extends HttpKernel
$currency = null;
if ($request->query->has("currency")) {
$currency = Model\CurrencyQuery::create()->findOneByCode($request->query->get("currency"));
if($currency) {
$this->container->get("event_dispatcher")->dispatch(TheliaEvents::CHANGE_DEFAULT_CURRENCY, new CurrencyEvent($currency));
}
} else {
$currency = $request->getSession()->getCurrency(false);
}