| @@ 8-48 (lines=41) @@ | ||
| 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 $product; |
|
| 19 | ||
| 20 | /** |
|
| 21 | * @var array|null |
|
| 22 | */ |
|
| 23 | private $options; |
|
| 24 | ||
| 25 | /** |
|
| 26 | * @var int |
|
| 27 | */ |
|
| 28 | private $quantity; |
|
| 29 | ||
| 30 | /** |
|
| 31 | * @param Request $request |
|
| 32 | */ |
|
| 33 | public function __construct(Request $request) |
|
| 34 | { |
|
| 35 | $this->token = $request->attributes->get('token'); |
|
| 36 | $this->product = $request->request->get('productCode'); |
|
| 37 | $this->options = $request->request->get('options'); |
|
| 38 | $this->quantity = $request->request->getInt('quantity'); |
|
| 39 | } |
|
| 40 | ||
| 41 | /** |
|
| 42 | * @return PutOptionBasedConfigurableItemToCart |
|
| 43 | */ |
|
| 44 | public function getCommand() |
|
| 45 | { |
|
| 46 | return new PutOptionBasedConfigurableItemToCart($this->token, $this->product, $this->options, $this->quantity); |
|
| 47 | } |
|
| 48 | } |
|
| 49 | ||
| @@ 8-48 (lines=41) @@ | ||
| 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 $product; |
|
| 19 | ||
| 20 | /** |
|
| 21 | * @var string |
|
| 22 | */ |
|
| 23 | private $variant; |
|
| 24 | ||
| 25 | /** |
|
| 26 | * @var int |
|
| 27 | */ |
|
| 28 | private $quantity; |
|
| 29 | ||
| 30 | /** |
|
| 31 | * @param Request $request |
|
| 32 | */ |
|
| 33 | public function __construct(Request $request) |
|
| 34 | { |
|
| 35 | $this->token = $request->attributes->get('token'); |
|
| 36 | $this->product = $request->request->get('productCode'); |
|
| 37 | $this->variant = $request->request->get('variantCode'); |
|
| 38 | $this->quantity = $request->request->getInt('quantity'); |
|
| 39 | } |
|
| 40 | ||
| 41 | /** |
|
| 42 | * @return PutVariantBasedConfigurableItemToCart |
|
| 43 | */ |
|
| 44 | public function getCommand() |
|
| 45 | { |
|
| 46 | return new PutVariantBasedConfigurableItemToCart($this->token, $this->product, $this->variant, $this->quantity); |
|
| 47 | } |
|
| 48 | } |
|
| 49 | ||