src/Entity/ObjetType.php line 14

Open in your IDE?
  1. <?php
  2. // src/Entity/ObjetType.php
  3. namespace App\Entity;
  4. use App\Repository\ObjetTypeRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. #[ORM\Entity(repositoryClassObjetTypeRepository::class)]
  10. #[ORM\Table(name'objet_type')]
  11. #[ORM\HasLifecycleCallbacks]
  12. class ObjetType
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column]
  17.     private ?int $id null;
  18.     #[ORM\Column(length255)]
  19.     private ?string $label null;
  20.     #[ORM\Column(name'label_pluriel'length100nullabletrue)]
  21.     private ?string $labelPluriel null;
  22.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  23.     private ?string $path null;
  24.     #[ORM\Column(typeTypes::INTEGERoptions: ['default' => 1])]
  25.     private int $etat 1;
  26.     #[ORM\Column(typeTypes::BIGINTnullabletrue)]
  27.     private ?string $numerotation null;
  28.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  29.     private ?string $config_label null;
  30.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  31.     private ?string $config_resume null;
  32.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  33.     private ?string $config_vignette_label null;
  34.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  35.     private ?string $config_vignette_resume null;
  36.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  37.     private ?string $icone null;
  38.     #[ORM\ManyToOne(inversedBy'objetTypes')]
  39.     #[ORM\JoinColumn(onDelete'SET NULL'nullabletrue)]
  40.     private ?ContactType $contact_group null;
  41.     #[ORM\ManyToMany(targetEntityVariablesGroup::class, mappedBy'objet_group')]
  42.     #[ORM\OrderBy(['ordre' => 'ASC'])]
  43.     private Collection $variablesGroups;
  44.     #[ORM\OneToMany(
  45.         mappedBy'objet_type',
  46.         targetEntityObjet::class,
  47.         cascade: ['remove'],
  48.         orphanRemovaltrue
  49.     )]
  50.     private Collection $objets;
  51.     #[ORM\ManyToOne(targetEntityself::class, inversedBy'childObjetTypes')]
  52.     private ?self $objetType null;
  53.     #[ORM\OneToMany(
  54.         mappedBy'objetType',
  55.         targetEntityself::class,
  56.         cascade: ['remove'],
  57.         orphanRemovaltrue
  58.     )]
  59.     private Collection $childObjetTypes;
  60.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  61.     private ?\DateTimeInterface $date_creation null;
  62.     public function __construct()
  63.     {
  64.         $this->variablesGroups = new ArrayCollection();
  65.         $this->objets = new ArrayCollection();
  66.         $this->childObjetTypes = new ArrayCollection();
  67.     }
  68.     // ---------------------
  69.     // Getters & Setters
  70.     // ---------------------
  71.     public function getId(): ?int
  72.     {
  73.         return $this->id;
  74.     }
  75.     public function getLabel(): ?string
  76.     {
  77.         return $this->label;
  78.     }
  79.     public function setLabel(string $label): static
  80.     {
  81.         $this->label ucfirst(trim($label));
  82.         return $this;
  83.     }
  84.     public function getLabelPluriel(): ?string
  85.     {
  86.         return $this->labelPluriel;
  87.     }
  88.     public function setLabelPluriel(?string $labelPluriel): static
  89.     {
  90.         $this->labelPluriel $labelPluriel ucfirst(trim($labelPluriel)) : null;
  91.         return $this;
  92.     }
  93.     public function getPath(): ?string
  94.     {
  95.         return $this->path;
  96.     }
  97.     public function setPath(?string $path): static
  98.     {
  99.         $this->path $path;
  100.         return $this;
  101.     }
  102.     public function getContactGroup(): ?ContactType
  103.     {
  104.         return $this->contact_group;
  105.     }
  106.     public function setContactGroup(?ContactType $contact_group): static
  107.     {
  108.         $this->contact_group $contact_group;
  109.         return $this;
  110.     }
  111.     /**
  112.      * @return Collection<int, VariablesGroup>
  113.      */
  114.     public function getVariablesGroups(): Collection
  115.     {
  116.         return $this->variablesGroups;
  117.     }
  118.     public function addVariablesGroup(VariablesGroup $variablesGroup): static
  119.     {
  120.         if (!$this->variablesGroups->contains($variablesGroup)) {
  121.             $this->variablesGroups->add($variablesGroup);
  122.             $variablesGroup->addObjetGroup($this);
  123.         }
  124.         return $this;
  125.     }
  126.     public function removeVariablesGroup(VariablesGroup $variablesGroup): static
  127.     {
  128.         if ($this->variablesGroups->removeElement($variablesGroup)) {
  129.             $variablesGroup->removeObjetGroup($this);
  130.         }
  131.         return $this;
  132.     }
  133.     /**
  134.      * @return Collection<int, Objet>
  135.      */
  136.     public function getObjets(): Collection
  137.     {
  138.         return $this->objets;
  139.     }
  140.     public function addObjet(Objet $objet): static
  141.     {
  142.         if (!$this->objets->contains($objet)) {
  143.             $this->objets->add($objet);
  144.             $objet->setObjetType($this);
  145.         }
  146.         return $this;
  147.     }
  148.     public function removeObjet(Objet $objet): static
  149.     {
  150.         if ($this->objets->removeElement($objet)) {
  151.             if ($objet->getObjetType() === $this) {
  152.                 $objet->setObjetType(null);
  153.             }
  154.         }
  155.         return $this;
  156.     }
  157.     public function getObjetType(): ?self
  158.     {
  159.         return $this->objetType;
  160.     }
  161.     public function setObjetType(?self $objetType): static
  162.     {
  163.         $this->objetType $objetType;
  164.         return $this;
  165.     }
  166.     /**
  167.      * @return Collection<int, self>
  168.      */
  169.     public function getchildObjetTypes(): Collection
  170.     {
  171.         return $this->childObjetTypes;
  172.     }
  173.     public function addChildObjet(self $childObjet): static
  174.     {
  175.         if (!$this->childObjetTypes->contains($childObjet)) {
  176.             $this->childObjetTypes->add($childObjet);
  177.             $childObjet->setObjetType($this);
  178.         }
  179.         return $this;
  180.     }
  181.     public function removeChildObjet(self $childObjet): static
  182.     {
  183.         if ($this->childObjetTypes->removeElement($childObjet)) {
  184.             if ($childObjet->getObjetType() === $this) {
  185.                 $childObjet->setObjetType(null);
  186.             }
  187.         }
  188.         return $this;
  189.     }
  190.     public function getDateCreation(): ?\DateTimeInterface
  191.     {
  192.         return $this->date_creation;
  193.     }
  194.     public function setDateCreation(?\DateTimeInterface $date_creation): static
  195.     {
  196.         $this->date_creation $date_creation;
  197.         return $this;
  198.     }
  199.     public function getEtat(): int
  200.     {
  201.         return $this->etat;
  202.     }
  203.     public function setEtat(int $etat): static
  204.     {
  205.         $this->etat $etat;
  206.         return $this;
  207.     }
  208.     public function getNumerotation(): ?string
  209.     {
  210.         return $this->numerotation;
  211.     }
  212.     public function setNumerotation(?string $numerotation): static
  213.     {
  214.         $this->numerotation $numerotation;
  215.         return $this;
  216.     }
  217.     public function getConfigLabel(): ?string
  218.     {
  219.         return $this->config_label;
  220.     }
  221.     public function setConfigLabel(?string $config_label): static
  222.     {
  223.         $this->config_label $config_label;
  224.         return $this;
  225.     }
  226.     public function getConfigResume(): ?string
  227.     {
  228.         return $this->config_resume;
  229.     }
  230.     public function setConfigResume(?string $config_resume): static
  231.     {
  232.         $this->config_resume $config_resume;
  233.         return $this;
  234.     }
  235.     public function getConfigVignetteLabel(): ?string
  236.     {
  237.         return $this->config_vignette_label;
  238.     }
  239.     public function setConfigVignetteLabel(?string $config_vignette_label): static
  240.     {
  241.         $this->config_vignette_label $config_vignette_label;
  242.         return $this;
  243.     }
  244.     public function getConfigVignetteResume(): ?string
  245.     {
  246.         return $this->config_vignette_resume;
  247.     }
  248.     public function setConfigVignetteResume(?string $config_vignette_resume): static
  249.     {
  250.         $this->config_vignette_resume $config_vignette_resume;
  251.         return $this;
  252.     }
  253.     public function getIcone(): ?string
  254.     {
  255.         return $this->icone;
  256.     }
  257.     public function setIcone(?string $icone): static
  258.     {
  259.         $this->icone $icone trim($icone) : null;
  260.         return $this;
  261.     }
  262.     // ---------------------
  263.     // Path logic only
  264.     // ---------------------
  265.     public function computePath(): void
  266.     {
  267.         $ids = [];
  268.         $parent $this->getObjetType();
  269.         while ($parent !== null) {
  270.             $ids[] = $parent->getId();
  271.             $parent $parent->getObjetType();
  272.         }
  273.         $ids array_reverse($ids);
  274.         $ids[] = $this->getId();
  275.         $this->path implode(','$ids);
  276.     }
  277. }