src/V4/Model/QuoteLineInfo/QuoteLineInfo.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\V4\Model\QuoteLineInfo;
  3. use ApiPlatform\Core\Annotation\ApiProperty;
  4. use App\Model\Category\Category;
  5. use App\Model\IriNormalizableInterface;
  6. use App\Model\NormalizeAsIRITrait;
  7. use App\Model\Product\Product;
  8. use App\Model\Traits\ImportableObjectTrait;
  9. use App\Model\Unit\Unit;
  10. use App\Model\Warranty\Warranty;
  11. use App\V4\Model\QuoteLine\QuoteLine;
  12. use App\V4\Model\QuoteLineInfoProductAttribute\QuoteLineInfoProductAttribute;
  13. use Doctrine\Common\Collections\ArrayCollection;
  14. use Doctrine\Common\Collections\Collection;
  15. use Symfony\Component\Serializer\Annotation\Groups;
  16. class QuoteLineInfo implements IriNormalizableInterface
  17. {
  18.     use ImportableObjectTrait;
  19.     use NormalizeAsIRITrait;
  20.     /**
  21.      * @ApiProperty(identifier=true)
  22.      *
  23.      * @var string|null
  24.      *
  25.      * @Groups({"list", "write_post_quote", "quote:write", "quote:read", "quote:update"})
  26.      */
  27.     private $id;
  28.     /**
  29.      * @var QuoteLine|null
  30.      *
  31.      * @Groups({"list", "write_post_quote", "quote:write", "quote:read", "quote:update"})
  32.      */
  33.     private $quoteLine;
  34.     /**
  35.      * @var Product|null
  36.      *
  37.      * @Groups({"list", "write_post_quote", "quote:write", "quote:read", "quote:update"})
  38.      */
  39.     private $product;
  40.     /**
  41.      * @var Warranty|null
  42.      */
  43.     private $warranty;
  44.     /**
  45.      * @var Category|null
  46.      */
  47.     private $category;
  48.     /**
  49.      * @var Unit|null
  50.      */
  51.     private $unit;
  52.     /**
  53.      * @var string|null
  54.      *
  55.      * @see QuoteLineEventSubscriber::class - field automatically
  56.      */
  57.     private $warrantyLabel;
  58.     /**
  59.      * @var string|null
  60.      *
  61.      * @see QuoteLineEventSubscriber::class - field automatically
  62.      */
  63.     private $unitLabel;
  64.     /**
  65.      * @var string|null
  66.      *
  67.      * @see QuoteLineEventSubscriber::class - field automatically
  68.      */
  69.     private $categoryLabel;
  70.     public function hasSubscriptionProduct(): bool
  71.     {
  72.         return $this->product instanceof Product
  73.             && $this->product->isSubscriptionProduct()
  74.         ;
  75.     }
  76.     /**
  77.      * @var QuoteLineInfoProductAttribute[]|Collection
  78.      *
  79.      * @Groups({"list", "new", "write_post_quote", "quote:write", "quote:read", "quote:update"})
  80.      */
  81.     private $quoteLineInfoProductAttributes;
  82.     public function __construct()
  83.     {
  84.         $this->quoteLineInfoProductAttributes = new ArrayCollection();
  85.     }
  86.     /**
  87.      * @return string|null
  88.      */
  89.     public function getId(): ?string
  90.     {
  91.         return $this->id;
  92.     }
  93.     /**
  94.      * @param string|null $id
  95.      *
  96.      * @return self
  97.      */
  98.     public function setId(?string $id): self
  99.     {
  100.         $this->id $id;
  101.         return $this;
  102.     }
  103.     /**
  104.      * @return QuoteLine|null
  105.      */
  106.     public function getQuoteLine(): ?QuoteLine
  107.     {
  108.         return $this->quoteLine;
  109.     }
  110.     /**
  111.      * @param QuoteLine|null $quoteLine
  112.      *
  113.      * @return self
  114.      */
  115.     public function setQuoteLine(?QuoteLine $quoteLine): self
  116.     {
  117.         $this->quoteLine $quoteLine;
  118.         return $this;
  119.     }
  120.     /**
  121.      * @return Product|null
  122.      */
  123.     public function getProduct(): ?Product
  124.     {
  125.         return $this->product;
  126.     }
  127.     /**
  128.      * @param Product|null $product
  129.      *
  130.      * @return self
  131.      */
  132.     public function setProduct(?Product $product): self
  133.     {
  134.         $this->product $product;
  135.         return $this;
  136.     }
  137.     /**
  138.      * @return Warranty|null
  139.      */
  140.     public function getWarranty(): ?Warranty
  141.     {
  142.         return $this->warranty;
  143.     }
  144.     /**
  145.      * @param Warranty|null $warranty
  146.      *
  147.      * @return self
  148.      */
  149.     public function setWarranty(?Warranty $warranty): self
  150.     {
  151.         $this->warranty $warranty;
  152.         return $this;
  153.     }
  154.     /**
  155.      * @return Category|null
  156.      */
  157.     public function getCategory(): ?Category
  158.     {
  159.         return $this->category;
  160.     }
  161.     /**
  162.      * @param Category|null $category
  163.      *
  164.      * @return self
  165.      */
  166.     public function setCategory(?Category $category): self
  167.     {
  168.         $this->category $category;
  169.         return $this;
  170.     }
  171.     /**
  172.      * @return Unit|null
  173.      */
  174.     public function getUnit(): ?Unit
  175.     {
  176.         return $this->unit;
  177.     }
  178.     /**
  179.      * @param Unit|null $unit
  180.      *
  181.      * @return self
  182.      */
  183.     public function setUnit(?Unit $unit): self
  184.     {
  185.         $this->unit $unit;
  186.         return $this;
  187.     }
  188.     /**
  189.      * @return string|null
  190.      */
  191.     public function getWarrantyLabel(): ?string
  192.     {
  193.         return $this->warrantyLabel;
  194.     }
  195.     /**
  196.      * @param string|null $warrantyLabel
  197.      *
  198.      * @return self
  199.      */
  200.     public function setWarrantyLabel(?string $warrantyLabel): self
  201.     {
  202.         $this->warrantyLabel $warrantyLabel;
  203.         return $this;
  204.     }
  205.     /**
  206.      * @return string|null
  207.      */
  208.     public function getUnitLabel(): ?string
  209.     {
  210.         return $this->unitLabel;
  211.     }
  212.     /**
  213.      * @param string|null $unitLabel
  214.      *
  215.      * @return self
  216.      */
  217.     public function setUnitLabel(?string $unitLabel): self
  218.     {
  219.         $this->unitLabel $unitLabel;
  220.         return $this;
  221.     }
  222.     /**
  223.      * @return string|null
  224.      */
  225.     public function getCategoryLabel(): ?string
  226.     {
  227.         return $this->categoryLabel;
  228.     }
  229.     /**
  230.      * @param string|null $categoryLabel
  231.      *
  232.      * @return self
  233.      */
  234.     public function setCategoryLabel(?string $categoryLabel): self
  235.     {
  236.         $this->categoryLabel $categoryLabel;
  237.         return $this;
  238.     }
  239.     /**
  240.      * @return Collection|QuoteLineInfoProductAttribute[]
  241.      */
  242.     public function getQuoteLineInfoProductAttributes(): Collection
  243.     {
  244.         return $this->quoteLineInfoProductAttributes;
  245.     }
  246.     /**
  247.      * @param Collection $quoteLineInfoProductAttributes
  248.      *
  249.      * @return $this
  250.      */
  251.     public function setQuoteLineInfoProductAttributes(Collection $quoteLineInfoProductAttributes): self
  252.     {
  253.         $this->quoteLineInfoProductAttributes $quoteLineInfoProductAttributes;
  254.         return $this;
  255.     }
  256.     /**
  257.      * @param QuoteLineInfoProductAttribute $quoteLineInfoProductAttribute
  258.      *
  259.      * @return $this
  260.      */
  261.     public function addQuoteLineInfoProductAttribute(QuoteLineInfoProductAttribute $quoteLineInfoProductAttribute): self
  262.     {
  263.         if (!$this->quoteLineInfoProductAttributes->contains($quoteLineInfoProductAttribute)) {
  264.             $this->quoteLineInfoProductAttributes[] = $quoteLineInfoProductAttribute;
  265.             $quoteLineInfoProductAttribute->setQuoteLineInfo($this);
  266.         }
  267.         return $this;
  268.     }
  269.     /**
  270.      * @param QuoteLineInfoProductAttribute $quoteLineInfoProductAttribute
  271.      *
  272.      * @return $this
  273.      */
  274.     public function removeQuoteLineInfoProductAttribute(QuoteLineInfoProductAttribute $quoteLineInfoProductAttribute): self
  275.     {
  276.         if ($this->quoteLineInfoProductAttributes->contains($quoteLineInfoProductAttribute)) {
  277.             $this->quoteLineInfoProductAttributes->removeElement($quoteLineInfoProductAttribute);
  278.             if ($quoteLineInfoProductAttribute->getQuoteLineInfo() === $this) {
  279.                 $quoteLineInfoProductAttribute->setQuoteLineInfo(null);
  280.             }
  281.         }
  282.         return $this;
  283.     }
  284. }