src/Entity/SectionMeta.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Enum\SectionMetaType;
  4. use App\Entity\Traits\Sortable;
  5. use App\Repository\SectionMetaRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Validator\Constraints\GreaterThanOrEqual;
  10. use Symfony\Component\Validator\Constraints\LessThanOrEqual;
  11. #[ORM\Entity(repositoryClassSectionMetaRepository::class)]
  12. class SectionMeta
  13. {
  14.     //TODO: amélioration - rajouter un champ isSaved pour savoir si c'est une donnée temporaire
  15.     use Sortable;
  16.     #[ORM\Id]
  17.     #[ORM\GeneratedValue]
  18.     #[ORM\Column(type'integer')]
  19.     private $id;
  20.     #[ORM\Column(type'string'length30enumTypeSectionMetaType::class)]
  21.     private $type;
  22.     #[ORM\Column(type'string'length100nullabletrue)]
  23.     private $slug;
  24.     #[ORM\Column(type'string'length100)]
  25.     private $name;
  26.     #[ORM\Column(type'json'nullabletrue)]
  27.     private $choices = [];
  28.     #[ORM\Column(type'boolean')]
  29.     private $isRequired;
  30.     #[ORM\Column(type'boolean')]
  31.     private $isMinor;
  32.     #[ORM\Column(type'boolean')]
  33.     private $isAdult;
  34.     #[ORM\Column(type'text'nullabletrue)]
  35.     private $comment;
  36.     #[ORM\Column(type'string'length150nullabletrue)]
  37.     private $help;
  38.     #[ORM\Column(type'smallint'nullabletrue)]
  39.     #[GreaterThanOrEqual(propertyPath'lengthMin'message"Le maximum doit être supérieur au minimum")]
  40.     private $lengthMax;
  41.     #[ORM\Column(type'smallint'nullabletrue)]
  42.     #[LessThanOrEqual(propertyPath'lengthMax'message"Le minimum doit être inférieur au maximum")]
  43.     private $lengthMin;
  44.     #[ORM\Column(type'boolean')]
  45.     private $isDisplayedRegistration;
  46.     #[ORM\Column(type'boolean')]
  47.     private $isDisplayedBackoffice;
  48.     #[ORM\ManyToOne(targetEntitySection::class, inversedBy'sectionMetas')]
  49.     #[ORM\JoinColumn(nullablefalse)]
  50.     private $section;
  51.     #[ORM\OneToMany(mappedBy'sectionMeta'targetEntitySectionPersonMeta::class)]
  52.     private $sectionPersonMetas;
  53.     public function __construct()
  54.     {
  55.         $this->sectionPersonMetas = new ArrayCollection();
  56.     }
  57.     public function getId(): ?int
  58.     {
  59.         return $this->id;
  60.     }
  61.     public function getType(): ?Enum\SectionMetaType
  62.     {
  63.         return $this->type;
  64.     }
  65.     public function setType(Enum\SectionMetaType $type): self
  66.     {
  67.         $this->type $type;
  68.         return $this;
  69.     }
  70.     public function getSlug(): ?string
  71.     {
  72.         return $this->slug;
  73.     }
  74.     public function setSlug(?string $slug): self
  75.     {
  76.         $this->slug $slug;
  77.         return $this;
  78.     }
  79.     public function getName(): ?string
  80.     {
  81.         return $this->name;
  82.     }
  83.     public function setName(string $name): self
  84.     {
  85.         $this->name $name;
  86.         return $this;
  87.     }
  88.     public function getChoices(): ?array
  89.     {
  90.         return $this->choices;
  91.     }
  92.     public function setChoices(?array $choices): self
  93.     {
  94.         $this->choices $choices;
  95.         return $this;
  96.     }
  97.     public function getIsRequired(): ?bool
  98.     {
  99.         return $this->isRequired;
  100.     }
  101.     public function setIsRequired(bool $isRequired): self
  102.     {
  103.         $this->isRequired $isRequired;
  104.         return $this;
  105.     }
  106.     public function getIsMinor(): ?bool
  107.     {
  108.         return $this->isMinor;
  109.     }
  110.     public function setIsMinor(bool $isMinor): self
  111.     {
  112.         $this->isMinor $isMinor;
  113.         return $this;
  114.     }
  115.     public function getIsAdult(): ?bool
  116.     {
  117.         return $this->isAdult;
  118.     }
  119.     public function setIsAdult(bool $isAdult): self
  120.     {
  121.         $this->isAdult $isAdult;
  122.         return $this;
  123.     }
  124.     public function getComment(): ?string
  125.     {
  126.         return $this->comment;
  127.     }
  128.     public function setComment(?string $comment): self
  129.     {
  130.         $this->comment $comment;
  131.         return $this;
  132.     }
  133.     public function getHelp(): ?string
  134.     {
  135.         return $this->help;
  136.     }
  137.     public function setHelp(?string $help): self
  138.     {
  139.         $this->help $help;
  140.         return $this;
  141.     }
  142.     public function getLengthMax(): ?int
  143.     {
  144.         return $this->lengthMax;
  145.     }
  146.     public function setLengthMax(?int $lengthMax): self
  147.     {
  148.         $this->lengthMax $lengthMax;
  149.         return $this;
  150.     }
  151.     public function getLengthMin(): ?int
  152.     {
  153.         return $this->lengthMin;
  154.     }
  155.     public function setLengthMin(?int $lengthMin): self
  156.     {
  157.         $this->lengthMin $lengthMin;
  158.         return $this;
  159.     }
  160.     public function getIsDisplayedRegistration(): ?bool
  161.     {
  162.         return $this->isDisplayedRegistration;
  163.     }
  164.     public function setIsDisplayedRegistration(bool $isDisplayedRegistration): self
  165.     {
  166.         $this->isDisplayedRegistration $isDisplayedRegistration;
  167.         return $this;
  168.     }
  169.     public function getIsDisplayedBackoffice(): ?bool
  170.     {
  171.         return $this->isDisplayedBackoffice;
  172.     }
  173.     public function setIsDisplayedBackoffice(bool $isDisplayedBackoffice): self
  174.     {
  175.         $this->isDisplayedBackoffice $isDisplayedBackoffice;
  176.         return $this;
  177.     }
  178.     public function getSection(): ?Section
  179.     {
  180.         return $this->section;
  181.     }
  182.     public function setSection(?Section $section): self
  183.     {
  184.         $this->section $section;
  185.         return $this;
  186.     }
  187.     /**
  188.      * @return Collection<int, SectionPersonMeta>
  189.      */
  190.     public function getSectionPersonMetas(): Collection
  191.     {
  192.         return $this->sectionPersonMetas;
  193.     }
  194.     public function addSectionPersonMeta(SectionPersonMeta $sectionPersonMeta): self
  195.     {
  196.         if (!$this->sectionPersonMetas->contains($sectionPersonMeta)) {
  197.             $this->sectionPersonMetas[] = $sectionPersonMeta;
  198.             $sectionPersonMeta->setSectionMeta($this);
  199.         }
  200.         return $this;
  201.     }
  202.     public function removeSectionPersonMeta(SectionPersonMeta $sectionPersonMeta): self
  203.     {
  204.         if ($this->sectionPersonMetas->removeElement($sectionPersonMeta)) {
  205.             // set the owning side to null (unless already changed)
  206.             if ($sectionPersonMeta->getSectionMeta() === $this) {
  207.                 $sectionPersonMeta->setSectionMeta(null);
  208.             }
  209.         }
  210.         return $this;
  211.     }
  212. }