1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* WellCommerce Open-Source E-Commerce Platform |
4
|
|
|
* |
5
|
|
|
* This file is part of the WellCommerce package. |
6
|
|
|
* |
7
|
|
|
* (c) Adam Piotrowski <[email protected]> |
8
|
|
|
* |
9
|
|
|
* For the full copyright and license information, |
10
|
|
|
* please view the LICENSE file that was distributed with this source code. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace WellCommerce\Bundle\AppBundle\Controller\Front; |
14
|
|
|
|
15
|
|
|
use Symfony\Component\HttpFoundation\Response; |
16
|
|
|
use WellCommerce\Bundle\CoreBundle\Controller\Front\AbstractFrontController; |
17
|
|
|
use WellCommerce\Bundle\OrderBundle\Entity\Order; |
18
|
|
|
use WellCommerce\Bundle\OrderBundle\Entity\OrderProduct; |
19
|
|
|
use WellCommerce\Bundle\OrderBundle\Manager\OrderProductManager; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Class ClientOrderController |
23
|
|
|
* |
24
|
|
|
* @author Adam Piotrowski <[email protected]> |
25
|
|
|
*/ |
26
|
|
|
class ClientOrderController extends AbstractFrontController |
27
|
|
|
{ |
28
|
|
|
public function indexAction(): Response |
29
|
|
|
{ |
30
|
|
|
return $this->displayTemplate('index'); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function viewAction(): Response |
34
|
|
|
{ |
35
|
|
|
return $this->displayTemplate('view'); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function repeatAction(Order $repeatedOrder): Response |
39
|
|
|
{ |
40
|
|
|
/** @var OrderProductManager $orderProductManager */ |
41
|
|
|
$orderProductManager = $this->get('order_product.manager'); |
42
|
|
|
$currentOrder = $this->getOrderProvider()->getCurrentOrder(); |
43
|
|
|
$client = $this->getSecurityHelper()->getAuthenticatedClient(); |
44
|
|
|
if ($client->getId() === $repeatedOrder->getClient()->getId()) { |
45
|
|
|
$repeatedOrder->getProducts()->map(function (OrderProduct $orderProduct) use ($currentOrder, $orderProductManager) { |
46
|
|
|
$orderProductManager->addProductToOrder( |
47
|
|
|
$orderProduct->getProduct(), |
48
|
|
|
$orderProduct->getVariant(), |
49
|
|
|
$orderProduct->getQuantity(), |
50
|
|
|
$currentOrder |
51
|
|
|
); |
52
|
|
|
}); |
53
|
|
|
|
54
|
|
|
return $this->redirectToRoute('front.cart.index'); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
return $this->redirectToAction('index'); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|