<?php
declare(strict_types=1);
namespace Crea\ParameterBundle\Entity;
use Crea\ParameterBundle\Annotation\CreateParameterFixtureValidator;
use Crea\ParameterBundle\Annotation\CreateParameterFormValidator;
use Crea\ParameterBundle\Annotation\UpdateParameterFixtureValidator;
use Crea\ParameterBundle\Annotation\UpdateParameterFormValidator;
use Crea\ParameterBundle\Repository\ParameterRepository;
use Crea\ToolsBundle\Entity\LifecycleUserIdentifierTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=ParameterRepository::class)
*
* @CreateParameterFixtureValidator(groups={"create_parameter_fixture_validator"})
* @UpdateParameterFixtureValidator(groups={"update_parameter_fixture_validator"})
* @CreateParameterFormValidator(groups={"create_parameter_form_validator"})
* @UpdateParameterFormValidator(groups={"update_parameter_form_validator"})
*
* @ORM\Table(name="parameter")
*/
class Parameter
{
use LifecycleUserIdentifierTrait;
/**
* @ORM\Id()
*
* @ORM\GeneratedValue()
*
* @ORM\Column(type="integer")
*/
protected int $id;
/**
* @ORM\ManyToOne(targetEntity="ParameterType", inversedBy="parameters")
*
* @ORM\JoinColumn(nullable=false)
*/
protected ParameterType $parameterType;
/**
* @ORM\Column(type="string", length=255, nullable=false)
*/
protected ?string $label = null;
/**
* @ORM\Column(type="string", length=255, nullable=false)
*/
protected ?string $code = null;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected ?string $description = null;
/**
* @ORM\Column(type="boolean", nullable=false, options={"default" : 1})
*/
protected bool $defaultParameter = false;
/**
* @ORM\Column(type="integer", nullable=false, options={"default" : 1})
*/
private int $displayIndex = 1;
/**
* @ORM\Column(type="boolean", nullable=false, options={"default" : 1})
*/
protected bool $active = true;
/**
* @var Collection<int, ParameterAttributeValue>
*
* @ORM\OneToMany(targetEntity=ParameterAttributeValue::class, mappedBy="parameter", orphanRemoval=true, cascade={"all"})
*/
private Collection $parameterAttributeValues;
public function __construct()
{
$this->parameterAttributeValues = new ArrayCollection();
}
public function getId(): int
{
return $this->id;
}
public function setId(int $id): self
{
$this->id = $id;
return $this;
}
public function getParameterType(): ParameterType
{
return $this->parameterType;
}
public function setParameterType(ParameterType $parameterType): self
{
$this->parameterType = $parameterType;
return $this;
}
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(?string $label): self
{
$this->label = $label;
return $this;
}
public function getCode(): ?string
{
return $this->code;
}
public function setCode(?string $code): self
{
$this->code = $code;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function isDefaultParameter(): bool
{
return $this->defaultParameter;
}
public function setDefaultParameter(bool $defaultParameter): self
{
$this->defaultParameter = $defaultParameter;
return $this;
}
public function getDisplayIndex(): int
{
return $this->displayIndex;
}
public function setDisplayIndex(int $displayIndex): self
{
$this->displayIndex = $displayIndex;
return $this;
}
public function isActive(): bool
{
return $this->active;
}
public function setActive(bool $active): self
{
$this->active = $active;
return $this;
}
/**
* @return Collection<int, ParameterAttributeValue>
*/
public function getParameterAttributeValues(): Collection
{
return $this->parameterAttributeValues;
}
/**
* @param Collection<int, ParameterAttributeValue> $parameterAttributeValues
*/
public function setParameterAttributeValues(Collection $parameterAttributeValues): self
{
$this->parameterAttributeValues = $parameterAttributeValues;
return $this;
}
public function addParameterAttributeValue(ParameterAttributeValue $parameterAttributeValue): self
{
if (!$this->parameterAttributeValues->contains($parameterAttributeValue)) {
$this->parameterAttributeValues[] = $parameterAttributeValue;
$parameterAttributeValue->setParameter($this);
}
return $this;
}
public function removeParameterAttributeValue(ParameterAttributeValue $parameterAttributeValue): self
{
if ($this->parameterAttributeValues->removeElement($parameterAttributeValue)) {
if ($parameterAttributeValue->getParameter() === $this) {
$parameterAttributeValue->setParameter(null);
}
}
return $this;
}
}