From a4c8df366b0dc56408f9eca07b10b939128cae30 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Mon, 16 Sep 2013 09:07:53 +0200 Subject: [PATCH] dispatch event when default currency change --- core/lib/Thelia/Core/Event/TheliaEvents.php | 2 ++ core/lib/Thelia/Core/TheliaHttpKernel.php | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index 54f05c0c0..7215cadbf 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -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"; diff --git a/core/lib/Thelia/Core/TheliaHttpKernel.php b/core/lib/Thelia/Core/TheliaHttpKernel.php index cf1d35195..fa1593fe5 100755 --- a/core/lib/Thelia/Core/TheliaHttpKernel.php +++ b/core/lib/Thelia/Core/TheliaHttpKernel.php @@ -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); }