mirror of
https://github.com/kevinveenbirkenbach/coding-challenge-online-shop.git
synced 2025-09-09 11:27:13 +02:00
In between commit implementing basket
This commit is contained in:
@@ -2,6 +2,10 @@
|
||||
namespace controller\order;
|
||||
|
||||
use controller\AbstractDefaultController;
|
||||
use core\CoreInterface;
|
||||
use repository\order\OrderInterface as OrderRepositoryInterface;
|
||||
use repository\product\ProductInterface as ProductRepositoryInterface;
|
||||
use repository\product\Product as ProductRepository;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -10,15 +14,48 @@ use controller\AbstractDefaultController;
|
||||
*/
|
||||
final class Order extends AbstractDefaultController implements OrderInterface
|
||||
{
|
||||
public function addProduct(): void
|
||||
{}
|
||||
|
||||
public function store(): void
|
||||
/**
|
||||
*
|
||||
* @var OrderRepositoryInterface
|
||||
*/
|
||||
protected $orderRepository;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var ProductRepositoryInterface
|
||||
*/
|
||||
protected $productRepository;
|
||||
|
||||
public function __construct(CoreInterface $core)
|
||||
{
|
||||
parent::__construct($core);
|
||||
$this->productRepository = new ProductRepository($this->core);
|
||||
}
|
||||
|
||||
private function addProduct(): void
|
||||
{
|
||||
$this->core->getBasket()->addProduct($this->productRepository->getById($this->post['add']));
|
||||
}
|
||||
|
||||
private function store(): void
|
||||
{}
|
||||
|
||||
public function basket(): void
|
||||
{
|
||||
$this->render('order/basket.html.twig',['basket'=>$this->core->getBasket()]);
|
||||
if ($this->post) {
|
||||
$this->postRoutine();
|
||||
}
|
||||
$this->render('order/basket.html.twig', [
|
||||
'basket' => $this->core->getBasket()
|
||||
]);
|
||||
}
|
||||
|
||||
private function postRoutine(): void
|
||||
{
|
||||
if ($this->post['add']) {
|
||||
$this->addProduct();
|
||||
}
|
||||
}
|
||||
|
||||
public function selectPaymentMethod(): void
|
||||
|
Reference in New Issue
Block a user