<?php
namespace App\V4\Model\QuoteLineInfo;
use ApiPlatform\Core\Annotation\ApiProperty;
use App\Model\Category\Category;
use App\Model\IriNormalizableInterface;
use App\Model\NormalizeAsIRITrait;
use App\Model\Product\Product;
use App\Model\Traits\ImportableObjectTrait;
use App\Model\Unit\Unit;
use App\Model\Warranty\Warranty;
use App\V4\Model\QuoteLine\QuoteLine;
use App\V4\Model\QuoteLineInfoProductAttribute\QuoteLineInfoProductAttribute;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Serializer\Annotation\Groups;
class QuoteLineInfo implements IriNormalizableInterface
{
use ImportableObjectTrait;
use NormalizeAsIRITrait;
/**
* @ApiProperty(identifier=true)
*
* @var string|null
*
* @Groups({"list", "write_post_quote", "quote:write", "quote:read", "quote:update"})
*/
private $id;
/**
* @var QuoteLine|null
*
* @Groups({"list", "write_post_quote", "quote:write", "quote:read", "quote:update"})
*/
private $quoteLine;
/**
* @var Product|null
*
* @Groups({"list", "write_post_quote", "quote:write", "quote:read", "quote:update"})
*/
private $product;
/**
* @var Warranty|null
*/
private $warranty;
/**
* @var Category|null
*/
private $category;
/**
* @var Unit|null
*/
private $unit;
/**
* @var string|null
*
* @see QuoteLineEventSubscriber::class - field automatically
*/
private $warrantyLabel;
/**
* @var string|null
*
* @see QuoteLineEventSubscriber::class - field automatically
*/
private $unitLabel;
/**
* @var string|null
*
* @see QuoteLineEventSubscriber::class - field automatically
*/
private $categoryLabel;
public function hasSubscriptionProduct(): bool
{
return $this->product instanceof Product
&& $this->product->isSubscriptionProduct()
;
}
/**
* @var QuoteLineInfoProductAttribute[]|Collection
*
* @Groups({"list", "new", "write_post_quote", "quote:write", "quote:read", "quote:update"})
*/
private $quoteLineInfoProductAttributes;
public function __construct()
{
$this->quoteLineInfoProductAttributes = new ArrayCollection();
}
/**
* @return string|null
*/
public function getId(): ?string
{
return $this->id;
}
/**
* @param string|null $id
*
* @return self
*/
public function setId(?string $id): self
{
$this->id = $id;
return $this;
}
/**
* @return QuoteLine|null
*/
public function getQuoteLine(): ?QuoteLine
{
return $this->quoteLine;
}
/**
* @param QuoteLine|null $quoteLine
*
* @return self
*/
public function setQuoteLine(?QuoteLine $quoteLine): self
{
$this->quoteLine = $quoteLine;
return $this;
}
/**
* @return Product|null
*/
public function getProduct(): ?Product
{
return $this->product;
}
/**
* @param Product|null $product
*
* @return self
*/
public function setProduct(?Product $product): self
{
$this->product = $product;
return $this;
}
/**
* @return Warranty|null
*/
public function getWarranty(): ?Warranty
{
return $this->warranty;
}
/**
* @param Warranty|null $warranty
*
* @return self
*/
public function setWarranty(?Warranty $warranty): self
{
$this->warranty = $warranty;
return $this;
}
/**
* @return Category|null
*/
public function getCategory(): ?Category
{
return $this->category;
}
/**
* @param Category|null $category
*
* @return self
*/
public function setCategory(?Category $category): self
{
$this->category = $category;
return $this;
}
/**
* @return Unit|null
*/
public function getUnit(): ?Unit
{
return $this->unit;
}
/**
* @param Unit|null $unit
*
* @return self
*/
public function setUnit(?Unit $unit): self
{
$this->unit = $unit;
return $this;
}
/**
* @return string|null
*/
public function getWarrantyLabel(): ?string
{
return $this->warrantyLabel;
}
/**
* @param string|null $warrantyLabel
*
* @return self
*/
public function setWarrantyLabel(?string $warrantyLabel): self
{
$this->warrantyLabel = $warrantyLabel;
return $this;
}
/**
* @return string|null
*/
public function getUnitLabel(): ?string
{
return $this->unitLabel;
}
/**
* @param string|null $unitLabel
*
* @return self
*/
public function setUnitLabel(?string $unitLabel): self
{
$this->unitLabel = $unitLabel;
return $this;
}
/**
* @return string|null
*/
public function getCategoryLabel(): ?string
{
return $this->categoryLabel;
}
/**
* @param string|null $categoryLabel
*
* @return self
*/
public function setCategoryLabel(?string $categoryLabel): self
{
$this->categoryLabel = $categoryLabel;
return $this;
}
/**
* @return Collection|QuoteLineInfoProductAttribute[]
*/
public function getQuoteLineInfoProductAttributes(): Collection
{
return $this->quoteLineInfoProductAttributes;
}
/**
* @param Collection $quoteLineInfoProductAttributes
*
* @return $this
*/
public function setQuoteLineInfoProductAttributes(Collection $quoteLineInfoProductAttributes): self
{
$this->quoteLineInfoProductAttributes = $quoteLineInfoProductAttributes;
return $this;
}
/**
* @param QuoteLineInfoProductAttribute $quoteLineInfoProductAttribute
*
* @return $this
*/
public function addQuoteLineInfoProductAttribute(QuoteLineInfoProductAttribute $quoteLineInfoProductAttribute): self
{
if (!$this->quoteLineInfoProductAttributes->contains($quoteLineInfoProductAttribute)) {
$this->quoteLineInfoProductAttributes[] = $quoteLineInfoProductAttribute;
$quoteLineInfoProductAttribute->setQuoteLineInfo($this);
}
return $this;
}
/**
* @param QuoteLineInfoProductAttribute $quoteLineInfoProductAttribute
*
* @return $this
*/
public function removeQuoteLineInfoProductAttribute(QuoteLineInfoProductAttribute $quoteLineInfoProductAttribute): self
{
if ($this->quoteLineInfoProductAttributes->contains($quoteLineInfoProductAttribute)) {
$this->quoteLineInfoProductAttributes->removeElement($quoteLineInfoProductAttribute);
if ($quoteLineInfoProductAttribute->getQuoteLineInfo() === $this) {
$quoteLineInfoProductAttribute->setQuoteLineInfo(null);
}
}
return $this;
}
}