<?php
namespace App\V4\Model\ProductAttribute;
use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Model\IriNormalizableInterface;
use App\Model\NormalizeAsIRITrait;
use App\Model\Traits\ImportableObjectTrait;
use App\Model\Traits\TimestampableTrait;
use App\V4\Model\ProductConfiguration\ProductConfiguration;
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/ProductAttribute",
* attributes={
* "api_allow_update": true
* },
* collectionOperations={
* "get": {
* "path": "/V4/product_attributes",
* "normalization_context": {
* "groups": {"product_attribute:list"},
* "isFromAdmin": true
* }
* },
* "post_tab": {
* "method": "POST",
* "deserialize": false,
* "write": false,
* "controller": "App\V4\Controller\ProductAttribute\ProductAttributeDataPersisterAction",
* "path": "/V4/product_attributes",
* "input_formats": {
* "multipart": {"multipart/form-data"}
* },
* "normalization_context": {
* "groups": {"product_attribute:read"}
* },
* "denormalization_context": {
* "groups": {}
* }
* },
* "get_form": {
* "method": "GET",
* "path": "/V4/product_attributes/form",
* "controller": App\V4\Controller\ProductAttribute\GetProductAttributeFormAction::class
* },
* },
* itemOperations={
* "get": {
* "path": "/V4/product_attributes/{id}",
* "normalization_context": {
* "groups": {"product_attribute:read"}
* }
* },
* "get_form": {
* "method": "GET",
* "path": "/V4/product_attributes/{id}/form",
* "controller": App\V4\Controller\ProductAttribute\GetProductAttributeFormAction::class,
* "normalization_context": {
* "isFromAdmin": true
* },
* },
* "put_product_attribute": {
* "method": "POST",
* "deserialize": false,
* "write": false,
* "controller": "App\V4\Controller\ProductAttribute\ProductAttributeDataPersisterAction",
* "path": "/V4/product_attributes/{id}",
* "input_formats": {
* "multipart": {"multipart/form-data"}
* },
* "normalization_context": {
* "groups": {"product_attribute:read"}
* },
* "denormalization_context": {
* "groups": {}
* }
* },
* "delete_product_attribute": {
* "method": "DELETE",
* "deserialize": false,
* "write": false,
* "controller": "App\V4\Controller\ProductAttribute\ProductAttributeDataPersisterAction",
* "path": "/V4/product_attributes/{id}",
* "normalization_context": {
* "isFromAdmin": true
* },
* }
* }
* )
*/
class ProductAttribute implements IriNormalizableInterface
{
use TimestampableTrait;
use ImportableObjectTrait;
use NormalizeAsIRITrait;
const TYPE_PROSPECT = 'prospect';
const TYPE_STRING = 'string';
const TYPE_INTEGER = 'integer';
const TYPE_BOOLEAN = 'boolean';
/**
* @ApiProperty(identifier=true)
*
* @var string|null
*
* @Groups({
* "list",
* "product_attribute:list", "product_attribute:read",
* "product_configuration:list", "product_configuration:read"
* })
*/
private $id;
/**
* @var string|null
*
* @Groups({
* "product_attribute:list", "product_attribute:read", "product_attribute:write"
* })
*/
private $customerId;
/**
* @var string
*
* @Groups({
* "list",
* "product_attribute:list", "product_attribute:read", "product_attribute:write", "product_attribute:update",
* "product_configuration:list", "product_configuration:read"
* })
*/
private $label;
/**
* @var string
*
* @Groups({
* "list",
* "product_attribute:list", "product_attribute:read", "product_attribute:write", "product_attribute:update"
* })
*/
private $type;
/**
* @MaxDepth(1)
*
* @var ProductConfiguration[]|Collection
*
* @Groups({
* "product_attribute:list", "product_attribute:read"
* })
*/
private $productConfigurations;
/**
* @var string|null
*
* @Groups({
* "list",
* "product_attribute:list", "product_attribute:read", "product_attribute:write", "product_attribute:update"
* })
*/
private $groupCode;
/**
* @var int
*
* @Groups({
* "list",
* "product_attribute:list", "product_attribute:read", "product_attribute:write", "product_attribute:update"
* })
*/
private $position;
/**
* @var string|null
*
* @Groups({
* "list",
* "product_attribute:list", "product_attribute:read", "product_attribute:write", "product_attribute:update"
* })
*/
private $defaultValueField;
public function __construct()
{
$this->productConfigurations = new ArrayCollection();
}
/**
* @return string|null
*/
public function getId(): ?string
{
return $this->id;
}
/**
* @param string|null $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 string|null
*/
public function getType(): ?string
{
return $this->type;
}
/**
* @param string $type
*
* @return $this
*/
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
/**
* @return Collection|ProductConfiguration[]
*/
public function getProductConfigurations(): Collection
{
return $this->productConfigurations;
}
/**
* @param Collection|ProductConfiguration[] $productConfigurations
*
* @return $this
*/
public function setProductConfigurations(Collection $productConfigurations): self
{
$this->productConfigurations = $productConfigurations;
return $this;
}
/**
* @param ProductConfiguration $productConfiguration
*
* @return $this
*/
public function addProductConfiguration(ProductConfiguration $productConfiguration): self
{
if (!$this->productConfigurations->contains($productConfiguration)) {
$this->productConfigurations[] = $productConfiguration;
$productConfiguration->addProductAttribute($this);
}
return $this;
}
/**
* @param ProductConfiguration $productConfiguration
*
* @return $this
*/
public function removeProductConfiguration(ProductConfiguration $productConfiguration): self
{
if ($this->productConfigurations->contains($productConfiguration)) {
$this->productConfigurations->removeElement($productConfiguration);
$productConfiguration->removeProductAttribute($this);
}
return $this;
}
/**
* @return string|null
*/
public function getGroupCode(): ?string
{
return $this->groupCode;
}
/**
* @param string|null $groupCode
*
* @return ProductAttribute
*/
public function setGroupCode(?string $groupCode): self
{
$this->groupCode = $groupCode;
return $this;
}
/**
* @return int|null
*/
public function getPosition(): ?int
{
return $this->position;
}
/**
* @param int $position
*
* @return ProductAttribute
*/
public function setPosition(int $position): self
{
$this->position = $position;
return $this;
}
/**
* @return string|null
*/
public function getDefaultValueField(): ?string
{
return $this->defaultValueField;
}
/**
* @param string|null $defaultValueField
*
* @return $this
*/
public function setDefaultValueField(?string $defaultValueField): self
{
$this->defaultValueField = $defaultValueField;
return $this;
}
}