productRepository = new ProductRepository($this->core); $this->orderRepository = new OrderRepository($this->core); } private function addProduct(): void { $this->core->getBasket()->addProduct($this->productRepository->getById($this->post['add'])); } private function store(): void {} public function basket(): void { if ($this->post) { $this->postRoutine(); } $this->render('order/basket.html.twig', [ 'basket' => $this->core->getBasket(), 'payment_methods'=>AbstractPayment::getPaymentMethods(), ]); } private function postRoutine(): void { if ($this->post['add']) { $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!'); } } } }