Пример #1
0
 /**
  * @param UuidInterface $orderId
  * @param User $user
  * @param Cart $cart
  * @param CartCalculatorInterface $cartCalculator
  * @param string $ip4
  * @param OrderAddress $shippingAddress
  * @param OrderAddress $billingAddress
  * @param CreditCard $creditCard
  * @return Order
  */
 public function createOrderFromCart(UuidInterface $orderId, User $user, Cart $cart, CartCalculatorInterface $cartCalculator, $ip4, OrderAddress $shippingAddress, OrderAddress $billingAddress, CreditCard $creditCard)
 {
     $this->throwValidationErrors($creditCard);
     $order = Order::fromCart($orderId, $user, $cart, $cartCalculator, $ip4);
     $order->setShippingAddress($shippingAddress);
     $order->setBillingAddress($billingAddress);
     $this->throwValidationErrors($order);
     $this->reserveProductsFromInventory($order);
     $this->addCreditCardPayment($order, $creditCard, $order->getTotal()->total);
     $this->orderRepository->create($order);
     $this->eventDispatcher->dispatchEvent(new OrderCreatedFromCartEvent($order->getId()));
     return $order;
 }
Пример #2
0
 public function update(User &$user)
 {
     $this->throwValidationErrors($user);
     $this->userRepository->update($user);
     $this->eventDispatcher->dispatch($user->releaseEvents());
 }