src/Entity/FormulaireFieldChoiceValue.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Gedmo\Mapping\Annotation as Gedmo;
  7. /**
  8.  * @ORM\Entity
  9.  * @ORM\Table(name="mmpp_form_field_choice_value")
  10.  */
  11. class FormulaireFieldChoiceValue
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\Column(type="integer")
  16.      * @ORM\GeneratedValue(strategy="AUTO")
  17.      */
  18.     protected $id;
  19.     /**
  20.      * @ORM\Column(type="integer", nullable=true)
  21.      * @var int
  22.      */
  23.     protected $position;
  24.     /**
  25.      * @ORM\Column(type="boolean", name="is_default")
  26.      * @var boolean
  27.      */
  28.     protected $isDefault;
  29.     /**
  30.      * @ORM\Column(type="string", length=255)
  31.      */
  32.     protected $value;
  33.     /**
  34.      * @Gedmo\Slug(fields={"value"}, updatable=false, separator="-", unique=false)
  35.      * @ORM\Column(type="string", length=255, unique=false)
  36.      * @var String
  37.      */
  38.     protected $slug;
  39.     /**
  40.      * @ORM\ManyToOne(targetEntity="FormulaireField", inversedBy="choiceValues")
  41.      * @ORM\JoinColumn(name="field_id", referencedColumnName="id")
  42.      */
  43.     protected ?FormulaireField $field;
  44.     /**
  45.      * @ORM\OneToMany(targetEntity="FormulaireField", mappedBy="dependsOn" )
  46.      * @var FormulaireField[]
  47.      */
  48.     protected $dependentFields;
  49.     public function __construct()
  50.     {
  51.         $this->dependentFields = new ArrayCollection();
  52.     }
  53.     /**
  54.      * toString for dependsOn list in backoffice
  55.      * @return string
  56.      */
  57.     public function __toString()
  58.     {
  59.         return $this->field->getLabel() . ' -> ' $this->value;
  60.     }
  61.     public function isIsDefault(): ?bool
  62.     {
  63.         return $this->isDefault;
  64.     }
  65.     public function getId(): ?int
  66.     {
  67.         return $this->id;
  68.     }
  69.     public function getPosition(): ?int
  70.     {
  71.         return $this->position;
  72.     }
  73.     public function setPosition(?int $position): self
  74.     {
  75.         $this->position $position;
  76.         return $this;
  77.     }
  78.     public function setIsDefault(bool $isDefault): self
  79.     {
  80.         $this->isDefault $isDefault;
  81.         return $this;
  82.     }
  83.     public function getValue(): ?string
  84.     {
  85.         return $this->value;
  86.     }
  87.     public function setValue(string $value): self
  88.     {
  89.         $this->value $value;
  90.         return $this;
  91.     }
  92.     public function getSlug(): ?string
  93.     {
  94.         return $this->slug;
  95.     }
  96.     public function setSlug(string $slug): self
  97.     {
  98.         $this->slug $slug;
  99.         return $this;
  100.     }
  101.     public function getField(): ?FormulaireField
  102.     {
  103.         return $this->field;
  104.     }
  105.     public function setField(?FormulaireField $field): self
  106.     {
  107.         $this->field $field;
  108.         return $this;
  109.     }
  110.     /**
  111.      * @return Collection<int, FormulaireField>
  112.      */
  113.     public function getDependentFields(): Collection
  114.     {
  115.         return $this->dependentFields;
  116.     }
  117.     public function addDependentField(FormulaireField $dependentField): self
  118.     {
  119.         if (!$this->dependentFields->contains($dependentField)) {
  120.             $this->dependentFields->add($dependentField);
  121.             $dependentField->setDependsOn($this);
  122.         }
  123.         return $this;
  124.     }
  125.     public function removeDependentField(FormulaireField $dependentField): self
  126.     {
  127.         if ($this->dependentFields->removeElement($dependentField)) {
  128.             // set the owning side to null (unless already changed)
  129.             if ($dependentField->getDependsOn() === $this) {
  130.                 $dependentField->setDependsOn(null);
  131.             }
  132.         }
  133.         return $this;
  134.     }
  135. }