diff --git a/Config/config.xml b/Config/config.xml index 3b6b5d14c..42168a46a 100644 --- a/Config/config.xml +++ b/Config/config.xml @@ -8,24 +8,6 @@ - - - - - - - - - - - - @@ -35,5 +17,11 @@ + + + + + + diff --git a/Config/module.xml b/Config/module.xml index dd99482a4..003308b5e 100644 --- a/Config/module.xml +++ b/Config/module.xml @@ -7,12 +7,14 @@ Wish list - 1.1.0 + 1.2.0 Michaƫl Espeche mespeche@openstudio.fr + Gilles Bourgeat + gbourgeat@openstudio.fr classic - 2.1.0 + 2.3.0 prod \ No newline at end of file diff --git a/EventListener/CustomerListener.php b/EventListener/CustomerListener.php new file mode 100644 index 000000000..92542ce74 --- /dev/null +++ b/EventListener/CustomerListener.php @@ -0,0 +1,51 @@ + + */ +class CustomerListener implements EventSubscriberInterface +{ + /** @var RequestStack */ + protected $requestStack; + + /** @var SecurityContext */ + protected $securityContext; + + public function __construct(RequestStack $requestStack, SecurityContext $securityContext) + { + $this->requestStack = $requestStack; + $this->securityContext = $securityContext; + } + + public function customerLogout(Event $event) + { + $this->requestStack->getCurrentRequest()->getSession()->set(WishListController::SESSION_NAME, []); + } + + public function customerLogin(Event $event) + { + if ($this->securityContext->hasCustomerUser()) { + $ids = WishListQuery::create()->filterByCustomerId($this->securityContext->getCustomerUser()->getId())->select('id')->find()->toArray(); + + $this->requestStack->getCurrentRequest()->getSession()->set(WishListController::SESSION_NAME, $ids); + } + } + + public static function getSubscribedEvents() + { + return array( + TheliaEvents::CUSTOMER_LOGOUT => array("customerLogout", 128), + TheliaEvents::CUSTOMER_LOGIN => array("customerLogin", 64) + ); + } +}