<?php
declare(strict_types=1);
namespace Crea\ParameterBundle\Entity;
use Crea\ParameterBundle\Annotation\CreateParameterTypeFixtureValidator;
use Crea\ParameterBundle\Annotation\CreateParameterTypeFormValidator;
use Crea\ParameterBundle\Annotation\UpdateParameterTypeFixtureValidator;
use Crea\ParameterBundle\Annotation\UpdateParameterTypeFormValidator;
use Crea\ParameterBundle\Repository\ParameterTypeRepository;
use Crea\ToolsBundle\Entity\LifecycleUserIdentifierTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=ParameterTypeRepository::class)
*
* @CreateParameterTypeFixtureValidator(groups={"create_parameter_type_fixture_validator"})
* @UpdateParameterTypeFixtureValidator(groups={"update_parameter_type_fixture_validator"})
* @CreateParameterTypeFormValidator(groups={"create_parameter_type_form_validator"})
* @UpdateParameterTypeFormValidator(groups={"update_parameter_type_form_validator"})
*
* @ORM\Table(name="parameter_type")
*/
class ParameterType
{
use LifecycleUserIdentifierTrait;
/**
* @ORM\Id()
*
* @ORM\GeneratedValue()
*
* @ORM\Column(type="integer")
*/
protected int $id;
/**
* @ORM\ManyToOne(targetEntity=ParameterGroup::class, inversedBy="parameterTypes")
*
* @ORM\JoinColumn(nullable=false)
*/
protected ParameterGroup $parameterGroup;
/**
* @ORM\Column(type="string", length=255, nullable=false)
*/
protected string $label;
/**
* @ORM\Column(type="string", length=255, nullable=false)
*/
protected string $code;
/**
* @ORM\Column(type="text", nullable=true)
*/
protected ?string $description = null;
/**
* @var Collection<int, ParameterTypeAttribute>
*
* @ORM\OneToMany(targetEntity=ParameterTypeAttribute::class, mappedBy="parameterType", orphanRemoval=true, cascade={"all"})
*/
protected Collection $parameterTypeAttributes;
/**
* @var Collection<int, Parameter>
*
* @ORM\OneToMany(targetEntity=Parameter::class, mappedBy="parameterType", orphanRemoval=true, cascade={"all"})
*
* @ORM\OrderBy({"displayIndex" = "ASC"})
*/
protected Collection $parameters;
public function __construct()
{
$this->parameterTypeAttributes = new ArrayCollection();
$this->parameters = new ArrayCollection();
}
public function getId(): int
{
return $this->id;
}
public function setId(int $id): self
{
$this->id = $id;
return $this;
}
public function getParameterGroup(): ParameterGroup
{
return $this->parameterGroup;
}
public function setParameterGroup(ParameterGroup $parameterGroup): self
{
$this->parameterGroup = $parameterGroup;
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;
}
/**
* @return Collection<int, ParameterTypeAttribute>
*/
public function getParameterTypeAttributes(): Collection
{
return $this->parameterTypeAttributes;
}
/**
* @param Collection<int, ParameterTypeAttribute> $parameterTypeAttributes
*/
public function setParameterTypeAttributes(Collection $parameterTypeAttributes): self
{
$this->parameterTypeAttributes = $parameterTypeAttributes;
return $this;
}
public function addParameterTypeAttribute(ParameterTypeAttribute $parameterTypeAttribute): self
{
if (!$this->parameterTypeAttributes->contains($parameterTypeAttribute)) {
$this->parameterTypeAttributes[] = $parameterTypeAttribute;
$parameterTypeAttribute->setParameterType($this);
}
return $this;
}
public function removeParameterTypeAttribute(ParameterTypeAttribute $parameterTypeAttribute): self
{
if ($this->parameterTypeAttributes->removeElement($parameterTypeAttribute)) {
if ($parameterTypeAttribute->getParameterType() === $this) {
$parameterTypeAttribute->setParameterType(null);
}
}
return $this;
}
/**
* @return Collection<int, Parameter>
*/
public function getParameters(): Collection
{
return $this->parameters;
}
/**
* @param Collection<int, Parameter> $parameters
*/
public function setParameters(Collection $parameters): self
{
$this->parameters = $parameters;
return $this;
}
public function addParameter(Parameter $parameter): self
{
if (!$this->parameters->contains($parameter)) {
$this->parameters[] = $parameter;
$parameter->setParameterType($this);
}
return $this;
}
public function removeParameter(Parameter $parameter): self
{
$this->parameters->removeElement($parameter);
return $this;
}
}