Esempio n. 1
0
 /**
  * Tries to initialize cart if there is data in storage.
  * If not, returns new instance from resourceFactory
  *
  * @return CartInterface
  */
 private function provideCart()
 {
     $cartIdentifier = $this->cartContext->getCurrentCartIdentifier();
     if ($cartIdentifier !== null) {
         $cart = $this->cartRepository->find($cartIdentifier);
         if ($cart !== null) {
             return $cart;
         }
     }
     $cart = $this->cartFactory->createNew();
     $this->cartContext->setCurrentCartIdentifier($cart);
     return $cart;
 }
Esempio n. 2
0
 function it_sets_current_cart_identifier_when_setting_cart(CartContextInterface $cartContext, CartInterface $cart)
 {
     $cartContext->setCurrentCartIdentifier($cart)->shouldBeCalled();
     $this->setCart($cart);
 }
Esempio n. 3
0
 /**
  * {@inheritdoc}
  */
 public function setCart(CartInterface $cart)
 {
     $this->cart = $cart;
     $this->context->setCurrentCartIdentifier($cart);
 }