public function restoreCurrentCart(CartRestoreEvent $cartRestoreEvent, $eventName, EventDispatcherInterface $dispatcher)
    {
        $cookieName = ConfigQuery::read("cart.cookie_name", 'thelia_cart');
        $persistentCookie = ConfigQuery::read("cart.use_persistent_cookie", 1);

        $cart = null;

        if ($this->requestStack->getCurrentRequest()->cookies->has($cookieName) && $persistentCookie) {
            $cart = $this->managePersistentCart($cartRestoreEvent, $cookieName, $dispatcher);
        } elseif (!$persistentCookie) {
            $cart = $this->manageNonPersistentCookie($cartRestoreEvent, $dispatcher);
        }

        // Still no cart ? Create a new one.
        if (null === $cart) {
            $cart = $this->dispatchNewCart($dispatcher);
        }

        $cartRestoreEvent->setCart($cart);
    }
public function restoreCurrentCart(CartRestoreEvent $cartRestoreEvent, $eventName, EventDispatcherInterface $dispatcher)
    {
        $cookieName = ConfigQuery::read("cart.cookie_name", 'thelia_cart');
        $persistentCookie = ConfigQuery::read("cart.use_persistent_cookie", 1);

        $cart = null;

        if ($this->requestStack->getCurrentRequest()->cookies->has($cookieName) && $persistentCookie) {
            $cart = $this->managePersistentCart($cartRestoreEvent, $cookieName, $dispatcher);
        } elseif (!$persistentCookie) {
            $cart = $this->manageNonPersistentCookie($cartRestoreEvent, $dispatcher);
        }

        // Still no cart ? Create a new one.
        if (null === $cart) {
            $cart = $this->dispatchNewCart($dispatcher);
        }

        $cartRestoreEvent->setCart($cart);
    }
public function restoreCurrentCart ( CartRestoreEvent $ cartRestoreEvent , $ eventName , EventDispatcherInterface $ dispatcher ) { $ cookieName = ConfigQuery :: read ( "cart.cookie_name" , 'thelia_cart' ) ; $ persistentCookie = ConfigQuery :: read ( "cart.use_persistent_cookie" , 1 ) ; $ cart = null ; if ( $ this -> requestStack -> getCurrentRequest ( ) -> cookies -> has ( $ cookieName ) && $ persistentCookie ) { $ cart = $ this -> managePersistentCart ( $ cartRestoreEvent , $ cookieName , $ dispatcher ) ; } elseif ( ! $ persistentCookie ) { $ cart = $ this -> manageNonPersistentCookie ( $ cartRestoreEvent , $ dispatcher ) ; } // Still no cart ? Create a new one. if ( null === $ cart ) { $ cart = $ this -> dispatchNewCart ( $ dispatcher ) ; } $ cartRestoreEvent -> setCart ( $ cart ) ; }
Search if cart already exists in session. If not try to restore it from the cart cookie,
or duplicate an old one.

@param CartRestoreEvent $cartRestoreEvent
@param $eventName
@param EventDispatcherInterface $dispatcher
Search if cart already exists in session . If not try to restore it from the cart cookie or duplicate an old one .