<?php
namespace App\V4\Model\ProductConfiguration;
use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Model\IriNormalizableInterface;
use App\Model\NormalizeAsIRITrait;
use App\Model\Product\Product;
use App\Model\Traits\ImportableObjectTrait;
use App\Model\Traits\TimestampableTrait;
use App\V4\Model\ProductAttribute\ProductAttribute;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\MaxDepth;
/**
* @ApiResource(
* shortName="V4/ProductConfiguration",
* attributes={
* "api_allow_update": true
* },
* collectionOperations={
* "get": {
* "path": "/V4/product_configurations",
* "normalization_context": {
* "groups": {"product_configuration:list"},
* "isFromAdmin": true
* }
* },
* "post_tab": {
* "method": "POST",
* "deserialize": false,
* "write": false,
* "controller": "App\V4\Controller\ProductConfiguration\ProductConfigurationDataPersisterAction",
* "path": "/V4/product_configurations",
* "input_formats": {
* "multipart": {"multipart/form-data"}
* },
* "normalization_context": {
* "groups": {"product_configuration:read"}
* },
* "denormalization_context": {
* "groups": {}
* }
* },
* "get_form": {
* "method": "GET",
* "path": "/V4/product_configurations/form",
* "controller": App\V4\Controller\ProductConfiguration\GetProductConfigurationFormAction::class
* },
* },
* itemOperations={
* "get": {
* "path": "/V4/product_configurations/{id}",
* "normalization_context": {
* "groups": {"product_configuration:read"}
* }
* },
* "get_form": {
* "method": "GET",
* "path": "/V4/product_configurations/{id}/form",
* "controller": App\V4\Controller\ProductConfiguration\GetProductConfigurationFormAction::class,
* "normalization_context": {
* "isFromAdmin": true
* },
* },
* "put_product_configuration": {
* "method": "POST",
* "deserialize": false,
* "write": false,
* "controller": "App\V4\Controller\ProductConfiguration\ProductConfigurationDataPersisterAction",
* "path": "/V4/product_configurations/{id}",
* "input_formats": {
* "multipart": {"multipart/form-data"}
* },
* "normalization_context": {
* "groups": {"product_configuration:read"}
* },
* "denormalization_context": {
* "groups": {}
* }
* },
* "delete_product_configuration": {
* "method": "DELETE",
* "deserialize": false,
* "write": false,
* "controller": "App\V4\Controller\ProductConfiguration\ProductConfigurationDataPersisterAction",
* "path": "/V4/product_configurations/{id}",
* "normalization_context": {
* "isFromAdmin": true
* },
* }
* }
* )
*/
class ProductConfiguration implements IriNormalizableInterface
{
use TimestampableTrait;
use ImportableObjectTrait;
use NormalizeAsIRITrait;
/**
* @ApiProperty(identifier=true)
*
* @var string|null
*
* @Groups({
* "list",
* "product_configuration:list", "product_configuration:read",
* "product_attribute:list", "product_attribute:read",
* "product:list", "product:read"
* })
*/
private $id;
/**
* @var string|null
*
* @Groups({
* "product_configuration:list", "product_configuration:read", "product_configuration:write"
* })
*/
private $customerId;
/**
* @var string
*
* @Groups({
* "list",
* "product_configuration:list", "product_configuration:read", "product_configuration:write", "product_configuration:update",
* "product_attribute:list", "product_attribute:read",
* "product:list", "product:read"
* })
*/
private $label;
/**
* @MaxDepth(1)
*
* @var ProductAttribute[]|Collection
*
* @Groups({
* "list",
* "product_configuration:list", "product_configuration:read", "product_configuration:write", "product_configuration:update"
* })
*/
private $productAttributes;
/**
* @var Product[]|Collection
*/
private $products;
public function __construct()
{
$this->productAttributes = new ArrayCollection();
$this->products = new ArrayCollection();
}
/**
* @return string|null
*/
public function getId(): ?string
{
return $this->id;
}
/**
* @param string $id
*
* @return $this
*/
public function setId(string $id): self
{
$this->id = $id;
return $this;
}
/**
* @return string|null
*/
public function getCustomerId(): ?string
{
return $this->customerId;
}
/**
* @param string|null $customerId
*
* @return $this
*/
public function setCustomerId(?string $customerId): self
{
$this->customerId = $customerId;
return $this;
}
/**
* @return string|null
*/
public function getLabel(): ?string
{
return $this->label;
}
/**
* @param string $label
*
* @return $this
*/
public function setLabel(string $label): self
{
$this->label = $label;
return $this;
}
/**
* @return Collection|ProductAttribute[]
*/
public function getProductAttributes(): Collection
{
return $this->productAttributes;
}
/**
* @param Collection|ProductAttribute[] $productAttributes
*
* @return $this
*/
public function setProductAttributes(Collection $productAttributes): self
{
$this->productAttributes = $productAttributes;
return $this;
}
/**
* @param ProductAttribute $productAttribute
*
* @return $this
*/
public function addProductAttribute(ProductAttribute $productAttribute): self
{
if (!$this->productAttributes->contains($productAttribute)) {
$this->productAttributes[] = $productAttribute;
$productAttribute->addProductConfiguration($this);
}
return $this;
}
/**
* @param ProductAttribute $productAttribute
*
* @return $this
*/
public function removeProductAttribute(ProductAttribute $productAttribute): self
{
if ($this->productAttributes->contains($productAttribute)) {
$this->productAttributes->removeElement($productAttribute);
$productAttribute->removeProductConfiguration($this);
}
return $this;
}
/**
* @return Product[]|Collection
*/
public function getProducts()
{
return $this->products;
}
/**
* @param Product[]|Collection $products
*
* @return $this
*/
public function setProducts(Collection $products): self
{
$this->products = $products;
return $this;
}
/**
* @param Product $product
*
* @return $this
*/
public function addProduct(Product $product): self
{
if (!$this->products->contains($product)) {
$this->products[] = $product;
}
return $this;
}
/**
* @param Product $product
*
* @return $this
*/
public function removeProduct(Product $product): self
{
if ($this->products->contains($product)) {
$this->products->removeElement($product);
}
return $this;
}
}