1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file has been created by developers from BitBag. |
5
|
|
|
* Feel free to contact us once you face any issues or want to start |
6
|
|
|
* another great project. |
7
|
|
|
* You can find more information about us on https://bitbag.io and write us |
8
|
|
|
* an email on [email protected]. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
declare(strict_types=1); |
12
|
|
|
|
13
|
|
|
namespace BitBag\SyliusVueStorefrontPlugin\Factory\Cart; |
14
|
|
|
|
15
|
|
|
use BitBag\SyliusVueStorefrontPlugin\Factory\Cart\Totals\TotalsViewFactoryInterface; |
16
|
|
|
use BitBag\SyliusVueStorefrontPlugin\View\Cart\ShippingInformationView; |
17
|
|
|
use Sylius\Component\Core\Model\OrderInterface as SyliusOrderInterface; |
18
|
|
|
|
19
|
|
|
final class ShippingInformationViewFactory implements ShippingInformationViewFactoryInterface |
20
|
|
|
{ |
21
|
|
|
/** @var string */ |
22
|
|
|
private $shippingInformationViewClass; |
23
|
|
|
|
24
|
|
|
/** @var PaymentMethodViewFactoryInterface */ |
25
|
|
|
private $paymentMethodViewFactory; |
26
|
|
|
|
27
|
|
|
/** @var TotalsViewFactoryInterface */ |
28
|
|
|
private $totalsViewFactory; |
29
|
|
|
|
30
|
|
|
public function __construct( |
31
|
|
|
string $shippingInformationViewClass, |
32
|
|
|
PaymentMethodViewFactoryInterface $paymentMethodViewFactory, |
33
|
|
|
TotalsViewFactoryInterface $totalsViewFactory |
34
|
|
|
) { |
35
|
|
|
$this->shippingInformationViewClass = $shippingInformationViewClass; |
36
|
|
|
$this->paymentMethodViewFactory = $paymentMethodViewFactory; |
37
|
|
|
$this->totalsViewFactory = $totalsViewFactory; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function create(array $syliusPaymentMethods, SyliusOrderInterface $syliusOrder): ShippingInformationView |
41
|
|
|
{ |
42
|
|
|
/** @var ShippingInformationView $shippingInformationView */ |
43
|
|
|
$shippingInformationView = new $this->shippingInformationViewClass(); |
44
|
|
|
$shippingInformationView->payment_methods = $this->paymentMethodViewFactory->createList($syliusPaymentMethods); |
45
|
|
|
$shippingInformationView->totals = $this->totalsViewFactory->create($syliusOrder); |
46
|
|
|
|
47
|
|
|
return $shippingInformationView; |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|