<?php
namespace App\Entity\Declaration;
use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ORM\Entity
* @ORM\Table(name="brunex_declaration_definition")
* @ApiResource(
* routePrefix="/brunex/declaration",
* normalizationContext={"groups"={"definition"}},
* )
*/
class Definition
{
/**
* @var int
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({"product", "declaration"})
*/
protected $id;
/**
* @var string
* @ORM\Column(type="text")
* @Groups({"product", "definition", "declaration"})
*/
protected $defaultValue = '';
/**
* @var boolean
* @ORM\Column(type="integer")
* @Groups({"product", "definition", "declaration"})
*/
protected $active = true;
/**
* @var array
* @ORM\Column(type="array", nullable=true)
* @Groups({"product", "definition", "declaration"})
*/
protected $valueList = [];
/**
* @var Product
* @ORM\ManyToOne(targetEntity="Product", inversedBy="definitions")
* @ORM\JoinColumn(onDelete="CASCADE")
*/
protected $product;
/**
* @var Field
* @ORM\ManyToOne(targetEntity="Field")
* @ORM\JoinColumn(onDelete="SET NULL")
* @ORM\JoinColumn(onDelete="CASCADE")
* @Groups({"product", "definition"})
*/
protected $field;
public function __toString()
{
return 'Definition ' . $this->product . ':' . $this->field;
}
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @return string
*/
public function getDefaultValue()
{
return $this->defaultValue;
}
/**
* @param string $defaultValue
*
* @return Definition
*/
public function setDefaultValue($defaultValue)
{
$this->defaultValue = $defaultValue;
return $this;
}
/**
* @return array
*/
public function getValueList()
{
return $this->valueList;
}
/**
* @param array $valueList
*
* @return Definition
*/
public function setValueList(array $valueList)
{
$this->valueList = $valueList;
return $this;
}
/**
* @return Product
*/
public function getProduct()
{
return $this->product;
}
/**
* @param Product $product
*
* @return Definition
*/
public function setProduct($product)
{
$this->product = $product;
return $this;
}
/**
* @return Field
*/
public function getField()
{
return $this->field;
}
/**
* @param Field $field
*
* @return Definition
*/
public function setField($field)
{
$this->field = $field;
return $this;
}
/**
* @return bool
*/
public function isActive(): bool
{
return $this->active;
}
/**
* @param bool $active
*/
public function setActive(bool $active): void
{
$this->active = $active;
}
}