src/Entity/ContactType.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ContactTypeRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassContactTypeRepository::class)]
  9. class ContactType
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\Column(length255)]
  16.     private ?string $label null;
  17.     #[ORM\Column(length255nullabletrue)]
  18.     private ?string $labelPluriel null;
  19.     #[ORM\OneToMany(mappedBy'contact_type'targetEntityContact::class, cascade: ['remove'])]
  20.     private Collection $contacts;
  21.     #[ORM\ManyToMany(targetEntityVariablesGroup::class, mappedBy'contact_group')]
  22.     #[ORM\OrderBy(['ordre' => 'ASC'])]
  23.     private Collection $variablesGroups;
  24.     #[ORM\OneToMany(mappedBy'contact_group'targetEntityObjetType::class, cascade: ['remove'])]
  25.     private Collection $objetTypes;
  26.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  27.     private ?\DateTimeInterface $date_creation null;
  28.     #[ORM\Column(typeTypes::INTEGERoptions: ['default' => 1])]
  29.     private int $etat 1;
  30.     public function __construct()
  31.     {
  32.         $this->contacts = new ArrayCollection();
  33.         $this->variablesGroups = new ArrayCollection();
  34.         $this->objetTypes = new ArrayCollection();
  35.     }
  36.     public function getId(): ?int
  37.     {
  38.         return $this->id;
  39.     }
  40.     public function getLabel(): ?string
  41.     {
  42.         return $this->label;
  43.     }
  44.     public function setLabel(string $label): static
  45.     {
  46.         $this->label $label;
  47.         return $this;
  48.     }
  49.     public function getLabelPluriel(): ?string
  50.     {
  51.         return $this->labelPluriel;
  52.     }
  53.     public function setLabelPluriel(?string $labelPluriel): static
  54.     {
  55.         $this->labelPluriel $labelPluriel;
  56.         return $this;
  57.     }
  58.     /**
  59.      * @return Collection<int, Contact>
  60.      */
  61.     public function getContacts(): Collection
  62.     {
  63.         return $this->contacts;
  64.     }
  65.     public function addContact(Contact $contact): static
  66.     {
  67.         if (!$this->contacts->contains($contact)) {
  68.             $this->contacts->add($contact);
  69.             $contact->setContactType($this);
  70.         }
  71.         return $this;
  72.     }
  73.     public function removeContact(Contact $contact): static
  74.     {
  75.         if ($this->contacts->removeElement($contact)) {
  76.             if ($contact->getContactType() === $this) {
  77.                 $contact->setContactType(null);
  78.             }
  79.         }
  80.         return $this;
  81.     }
  82.     /**
  83.      * @return Collection<int, VariablesGroup>
  84.      */
  85.     public function getVariablesGroups(): Collection
  86.     {
  87.         $array $this->variablesGroups->toArray();
  88.         usort($array, fn($a$b) => $a->getOrdre() <=> $b->getOrdre());
  89.         return new ArrayCollection($array);
  90.     }
  91.     public function addVariablesGroup(VariablesGroup $variablesGroup): static
  92.     {
  93.         if (!$this->variablesGroups->contains($variablesGroup)) {
  94.             $this->variablesGroups->add($variablesGroup);
  95.             $variablesGroup->addContactGroup($this);
  96.         }
  97.         return $this;
  98.     }
  99.     public function removeVariablesGroup(VariablesGroup $variablesGroup): static
  100.     {
  101.         if ($this->variablesGroups->removeElement($variablesGroup)) {
  102.             $variablesGroup->removeContactGroup($this);
  103.         }
  104.         return $this;
  105.     }
  106.     /**
  107.      * @return Collection<int, ObjetType>
  108.      */
  109.     public function getObjetTypes(): Collection
  110.     {
  111.         return $this->objetTypes;
  112.     }
  113.     public function getObjetTypesLevelOne(): Collection
  114.     {
  115.         return $this->objetTypes->filter(
  116.             fn($objetType) => $objetType->getObjetType() === null
  117.         );
  118.     }
  119.     public function addObjetType(ObjetType $objetType): static
  120.     {
  121.         if (!$this->objetTypes->contains($objetType)) {
  122.             $this->objetTypes->add($objetType);
  123.             $objetType->setContactGroup($this);
  124.         }
  125.         return $this;
  126.     }
  127.     public function removeObjetType(ObjetType $objetType): static
  128.     {
  129.         if ($this->objetTypes->removeElement($objetType)) {
  130.             if ($objetType->getContactGroup() === $this) {
  131.                 $objetType->setContactGroup(null);
  132.             }
  133.         }
  134.         return $this;
  135.     }
  136.     public function getDateCreation(): ?\DateTimeInterface
  137.     {
  138.         return $this->date_creation;
  139.     }
  140.     public function setDateCreation(?\DateTimeInterface $date_creation): static
  141.     {
  142.         $this->date_creation $date_creation;
  143.         return $this;
  144.     }
  145.     public function getEtat(): int
  146.     {
  147.         return $this->etat;
  148.     }
  149.     public function setEtat(int $etat): static
  150.     {
  151.         $this->etat $etat;
  152.         return $this;
  153.     }
  154.     public function __toString()
  155.     {
  156.         return $this->label;
  157.     }
  158. }