Dumplie\Customer\Domain\Orders::exists PHP Method

exists() public method

public exists ( OrderId $id ) : boolean
$id OrderId
return boolean
    public function exists(OrderId $id) : bool;

Usage Example

Beispiel #1
0
 /**
  * @param PlaceOrder $command
  * @throws OrderAlreadyExistsException
  * @throws \Dumplie\Customer\Domain\Exception\EmptyCartException
  */
 public function handle(PlaceOrder $command)
 {
     $cartId = new CartId($command->cartId());
     $orderId = new OrderId($command->orderId());
     if ($this->orders->exists($orderId)) {
         throw OrderAlreadyExistsException::withId($orderId);
     }
     $checkout = $this->checkouts->getForCart($cartId);
     $order = $checkout->placeOrder($orderId, $this->products, $this->carts);
     $this->orders->add($order);
     $this->checkouts->removeForCart($cartId);
     $this->carts->remove($cartId);
     $this->eventLog->log(new CustomerPlacedOrder((string) $orderId));
 }