mirror of
https://github.com/kevinveenbirkenbach/coding-challenge-online-shop.git
synced 2024-11-01 00:53:10 +01:00
Solved transaction bug
This commit is contained in:
parent
541c472f15
commit
244b18a42f
@ -43,7 +43,10 @@ final class Order extends AbstractDefaultController implements OrderInterface
|
||||
}
|
||||
|
||||
private function store(): void
|
||||
{}
|
||||
{
|
||||
$this->core->getBasket()->setCustomer($this->core->getUser());
|
||||
$this->core->setBasket(new OrderEntity());
|
||||
}
|
||||
|
||||
public function basket(): void
|
||||
{
|
||||
@ -62,12 +65,7 @@ final class Order extends AbstractDefaultController implements OrderInterface
|
||||
$this->addProduct();
|
||||
}
|
||||
if ($this->post['store']){
|
||||
$this->core->getBasket()->setCustomer($this->core->getUser());
|
||||
if($this->orderRepository->saveOrder($this->core->getBasket())){
|
||||
$this->core->setBasket(new OrderEntity());
|
||||
}else{
|
||||
throw new \Exception('Order could not be saved!');
|
||||
}
|
||||
$this->store();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ final class Order extends AbstractRepository implements OrderInterface
|
||||
$this->database->beginTransaction();
|
||||
$this->saveOrderEntity($order);
|
||||
$this->saveConnection($order);
|
||||
return $this->database->rollBack();
|
||||
return $this->database->commit();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user