@@ 8-55 (lines=48) @@ | ||
5 | use Sylius\ShopApiPlugin\Command\PutOptionBasedConfigurableItemToCart; |
|
6 | use Symfony\Component\HttpFoundation\Request; |
|
7 | ||
8 | final class PutOptionBasedConfigurableItemToCartRequest |
|
9 | { |
|
10 | /** |
|
11 | * @var string |
|
12 | */ |
|
13 | private $token; |
|
14 | ||
15 | /** |
|
16 | * @var string |
|
17 | */ |
|
18 | private $productCode; |
|
19 | ||
20 | /** |
|
21 | * @var array|null |
|
22 | */ |
|
23 | private $options; |
|
24 | ||
25 | /** |
|
26 | * @var int |
|
27 | */ |
|
28 | private $quantity; |
|
29 | ||
30 | private function __construct($token, $productCode, $options, $quantity) |
|
31 | { |
|
32 | $this->token = $token; |
|
33 | $this->productCode = $productCode; |
|
34 | $this->options = $options; |
|
35 | $this->quantity = $quantity; |
|
36 | } |
|
37 | ||
38 | public static function fromArray(array $item) |
|
39 | { |
|
40 | return new self($item['token'] ?? null, $item['productCode'] ?? null, $item['options'] ?? null, $item['quantity'] ?? null); |
|
41 | } |
|
42 | ||
43 | public static function fromRequest(Request $request) |
|
44 | { |
|
45 | return new self($request->attributes->get('token'), $request->request->get('productCode'), $request->request->get('options'), $request->request->get('quantity')); |
|
46 | } |
|
47 | ||
48 | /** |
|
49 | * @return PutOptionBasedConfigurableItemToCart |
|
50 | */ |
|
51 | public function getCommand() |
|
52 | { |
|
53 | return new PutOptionBasedConfigurableItemToCart($this->token, $this->productCode, $this->options, $this->quantity); |
|
54 | } |
|
55 | } |
|
56 |
@@ 8-55 (lines=48) @@ | ||
5 | use Sylius\ShopApiPlugin\Command\PutVariantBasedConfigurableItemToCart; |
|
6 | use Symfony\Component\HttpFoundation\Request; |
|
7 | ||
8 | final class PutVariantBasedConfigurableItemToCartRequest |
|
9 | { |
|
10 | /** |
|
11 | * @var string |
|
12 | */ |
|
13 | private $token; |
|
14 | ||
15 | /** |
|
16 | * @var string |
|
17 | */ |
|
18 | private $productCode; |
|
19 | ||
20 | /** |
|
21 | * @var string |
|
22 | */ |
|
23 | private $variantCode; |
|
24 | ||
25 | /** |
|
26 | * @var int |
|
27 | */ |
|
28 | private $quantity; |
|
29 | ||
30 | private function __construct($token, $productCode, $variantCode, $quantity) |
|
31 | { |
|
32 | $this->token = $token; |
|
33 | $this->productCode = $productCode; |
|
34 | $this->variantCode = $variantCode; |
|
35 | $this->quantity = $quantity; |
|
36 | } |
|
37 | ||
38 | public static function fromArray(array $item) |
|
39 | { |
|
40 | return new self($item['token'] ?? null, $item['productCode'] ?? null, $item['variantCode'] ?? null, $item['quantity'] ?? null); |
|
41 | } |
|
42 | ||
43 | public static function fromRequest(Request $request) |
|
44 | { |
|
45 | return new self($request->attributes->get('token'), $request->request->get('productCode'), $request->request->get('variantCode'), $request->request->get('quantity')); |
|
46 | } |
|
47 | ||
48 | /** |
|
49 | * @return PutVariantBasedConfigurableItemToCart |
|
50 | */ |
|
51 | public function getCommand() |
|
52 | { |
|
53 | return new PutVariantBasedConfigurableItemToCart($this->token, $this->productCode, $this->variantCode, $this->quantity); |
|
54 | } |
|
55 | } |
|
56 |