From 244b18a42f263de2482c7f702647e28af890d28c Mon Sep 17 00:00:00 2001 From: Kevin Frantz Date: Sun, 15 Jul 2018 16:17:11 +0200 Subject: [PATCH] Solved transaction bug --- src/controller/order/Order.php | 12 +++++------- src/repository/order/Order.php | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/controller/order/Order.php b/src/controller/order/Order.php index 6c81133..183127b 100644 --- a/src/controller/order/Order.php +++ b/src/controller/order/Order.php @@ -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(); } } } diff --git a/src/repository/order/Order.php b/src/repository/order/Order.php index 9214c05..c65e7c6 100644 --- a/src/repository/order/Order.php +++ b/src/repository/order/Order.php @@ -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(); } /**