2018-07-14 18:50:47 +02:00
|
|
|
<?php
|
|
|
|
namespace controller\order;
|
|
|
|
|
2018-07-15 12:15:06 +02:00
|
|
|
use controller\AbstractDefaultController;
|
2018-07-15 13:09:06 +02:00
|
|
|
use core\CoreInterface;
|
|
|
|
use repository\order\OrderInterface as OrderRepositoryInterface;
|
|
|
|
use repository\product\ProductInterface as ProductRepositoryInterface;
|
|
|
|
use repository\product\Product as ProductRepository;
|
2018-07-15 14:32:56 +02:00
|
|
|
use entity\payment\AbstractPayment;
|
2018-07-14 18:50:47 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @author kevinfrantz
|
|
|
|
*
|
|
|
|
*/
|
2018-07-15 12:15:06 +02:00
|
|
|
final class Order extends AbstractDefaultController implements OrderInterface
|
2018-07-14 18:50:47 +02:00
|
|
|
{
|
|
|
|
|
2018-07-15 13:09:06 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @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
|
2018-07-14 18:50:47 +02:00
|
|
|
{}
|
|
|
|
|
|
|
|
public function basket(): void
|
2018-07-15 12:15:06 +02:00
|
|
|
{
|
2018-07-15 13:09:06 +02:00
|
|
|
if ($this->post) {
|
|
|
|
$this->postRoutine();
|
|
|
|
}
|
|
|
|
$this->render('order/basket.html.twig', [
|
2018-07-15 14:32:56 +02:00
|
|
|
'basket' => $this->core->getBasket(),
|
|
|
|
'payment_methods'=>AbstractPayment::getPaymentMethods(),
|
2018-07-15 13:09:06 +02:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function postRoutine(): void
|
|
|
|
{
|
|
|
|
if ($this->post['add']) {
|
|
|
|
$this->addProduct();
|
|
|
|
}
|
2018-07-15 12:15:06 +02:00
|
|
|
}
|
2018-07-14 18:50:47 +02:00
|
|
|
}
|
|
|
|
|