vendor/bitbag/product-bundle-plugin/src/Command/AddProductBundleToCartCommand.php line 18

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file was created by developers working at BitBag
  4.  * Do you need more information about us and what we do? Visit our https://bitbag.io website!
  5.  * We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
  6. */
  7. declare(strict_types=1);
  8. namespace BitBag\SyliusProductBundlePlugin\Command;
  9. use BitBag\SyliusProductBundlePlugin\Entity\OrderItemInterface;
  10. use BitBag\SyliusProductBundlePlugin\Entity\ProductBundleItemInterface;
  11. use BitBag\SyliusProductBundlePlugin\Entity\ProductInterface;
  12. use Sylius\Component\Order\Model\OrderInterface;
  13. final class AddProductBundleToCartCommand
  14. {
  15.     /** @var OrderInterface */
  16.     private $cart;
  17.     /** @var OrderItemInterface */
  18.     private $cartItem;
  19.     /** @var ProductInterface */
  20.     private $product;
  21.     /** @var AddProductBundleItemToCartCommand[] */
  22.     private $productBundleItems = [];
  23.     public function __construct(OrderInterface $cartOrderItemInterface $cartItemProductInterface $product)
  24.     {
  25.         $this->cart $cart;
  26.         $this->cartItem $cartItem;
  27.         $this->product $product;
  28.         /** @var ProductBundleItemInterface $productBundleItem */
  29.         foreach ($product->getProductBundle()->getProductBundleItems() as $productBundleItem) {
  30.             $this->productBundleItems[] = new AddProductBundleItemToCartCommand($productBundleItem);
  31.         }
  32.     }
  33.     public function getProduct(): ProductInterface
  34.     {
  35.         return $this->product;
  36.     }
  37.     public function getProductBundleItems(): array
  38.     {
  39.         return $this->productBundleItems;
  40.     }
  41.     public function getCart(): OrderInterface
  42.     {
  43.         return $this->cart;
  44.     }
  45.     public function getCartItem(): OrderItemInterface
  46.     {
  47.         return $this->cartItem;
  48.     }
  49. }