/**
  * Assign the Cart stored in session to the logged Customer.
  *
  * When a user has succesfully logged in, a check is needed
  * to see if a Cart was created in session when she was not
  * logged.
  *
  * @param AuthenticationEvent $event Event
  */
 public function onAuthenticationSuccess(AuthenticationEvent $event)
 {
     $loggedUser = $event->getAuthenticationToken()->getUser();
     $cart = $this->cartWrapper->getCartFromSession();
     if ($loggedUser instanceof CustomerInterface && ($cart instanceof CartInterface && $cart->getId())) {
         /*
          * We assume that a cart with an ID is
          * not a pristine entity coming from a
          * factory method. (i.e. has already been
          * flushed)
          */
         $cart->setCustomer($loggedUser);
         $this->cartManager->flush($cart);
     }
 }