Skip to content

Commit

Permalink
Merge pull request #980 from dpfaffenbauer/persist-cart-on-login
Browse files Browse the repository at this point in the history
[CoreBundle] persist customer on login if the cart has an id
  • Loading branch information
dpfaffenbauer authored May 8, 2019
2 parents 5a1952b + 69ed674 commit 5e227c2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,25 @@ final class CartBlamerListener
*/
private $cartContext;

/**
* @var CartManagerInterface
*/
private $cartManager;

/**
* @param CartProcessorInterface $cartProcessor
* @param CartContextInterface $cartContext
* @param CartManagerInterface $cartManager
*/
public function __construct(CartProcessorInterface $cartProcessor, CartContextInterface $cartContext)
public function __construct(
CartProcessorInterface $cartProcessor,
CartContextInterface $cartContext,
CartManagerInterface $cartManager
)
{
$this->cartProcessor = $cartProcessor;
$this->cartContext = $cartContext;
$this->cartManager = $cartManager;
}

/**
Expand Down Expand Up @@ -91,6 +102,13 @@ private function blame(CustomerInterface $user)
}

$this->cartProcessor->process($cart);

if ($cart->getId()) {
$this->cartManager->persistCart($cart);
return;
}

$this->cartProcessor->process($cart);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ services:
arguments:
- '@coreshop.cart_processor'
- '@coreshop.context.cart'
- '@coreshop.cart.manager'
tags:
- { name: kernel.event_listener, event: security.interactive_login, method: onInteractiveLogin }
- { name: kernel.event_listener, event: coreshop.customer.register, method: onRegisterEvent }
Expand Down

0 comments on commit 5e227c2

Please sign in to comment.