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\OneToMany(mappedBy'contact_type'targetEntityContact::class, cascade: ['remove'])]
  18.     private Collection $contacts;
  19.     #[ORM\ManyToMany(targetEntityVariablesGroup::class, mappedBy'contact_group')]
  20.     private Collection $variablesGroups;
  21.     #[ORM\OneToMany(mappedBy'contact_group'targetEntityProjectType::class, cascade: ['remove'])]
  22.     private Collection $projectTypes;
  23.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  24.     private ?\DateTimeInterface $date_creation null;
  25.     public function __construct()
  26.     {
  27.         $this->contacts = new ArrayCollection();
  28.         $this->variablesGroups = new ArrayCollection();
  29.         $this->projectTypes = new ArrayCollection();
  30.     }
  31.     public function getId(): ?int
  32.     {
  33.         return $this->id;
  34.     }
  35.     public function getLabel(): ?string
  36.     {
  37.         return $this->label;
  38.     }
  39.     public function setLabel(string $label): static
  40.     {
  41.         $this->label $label;
  42.         return $this;
  43.     }
  44.     /**
  45.      * @return Collection<int, Contact>
  46.      */
  47.     public function getContacts(): Collection
  48.     {
  49.         return $this->contacts;
  50.     }
  51.     public function addContact(Contact $contact): static
  52.     {
  53.         if (!$this->contacts->contains($contact)) {
  54.             $this->contacts->add($contact);
  55.             $contact->setContactType($this);
  56.         }
  57.         return $this;
  58.     }
  59.     public function removeContact(Contact $contact): static
  60.     {
  61.         if ($this->contacts->removeElement($contact)) {
  62.             // set the owning side to null (unless already changed)
  63.             if ($contact->getContactType() === $this) {
  64.                 $contact->setContactType(null);
  65.             }
  66.         }
  67.         return $this;
  68.     }
  69.     /**
  70.      * @return Collection<int, VariablesGroup>
  71.      */
  72.     public function getVariablesGroups(): Collection
  73.     {
  74.         // Convert to an array to sort
  75.         $array $this->variablesGroups->toArray();
  76.         // Sort the array using usort
  77.         usort($array, function($a$b) {
  78.             return $a->getOrdre() <=> $b->getOrdre();
  79.         });
  80.         // Convert back to ArrayCollection or PersistentCollection if needed
  81.         return new ArrayCollection($array);
  82.     }
  83.     public function addVariablesGroup(VariablesGroup $variablesGroup): static
  84.     {
  85.         if (!$this->variablesGroups->contains($variablesGroup)) {
  86.             $this->variablesGroups->add($variablesGroup);
  87.             $variablesGroup->addContactGroup($this);
  88.         }
  89.         return $this;
  90.     }
  91.     public function removeVariablesGroup(VariablesGroup $variablesGroup): static
  92.     {
  93.         if ($this->variablesGroups->removeElement($variablesGroup)) {
  94.             $variablesGroup->removeContactGroup($this);
  95.         }
  96.         return $this;
  97.     }
  98.     /**
  99.      * @return Collection<int, ProjectType>
  100.      */
  101.     public function getProjectTypes(): Collection
  102.     {
  103.         return $this->projectTypes;
  104.     }
  105.     public function addProjectType(ProjectType $projectType): static
  106.     {
  107.         if (!$this->projectTypes->contains($projectType)) {
  108.             $this->projectTypes->add($projectType);
  109.             $projectType->setContactGroup($this);
  110.         }
  111.         return $this;
  112.     }
  113.     public function removeProjectType(ProjectType $projectType): static
  114.     {
  115.         if ($this->projectTypes->removeElement($projectType)) {
  116.             // set the owning side to null (unless already changed)
  117.             if ($projectType->getContactGroup() === $this) {
  118.                 $projectType->setContactGroup(null);
  119.             }
  120.         }
  121.         return $this;
  122.     }
  123.     public function getDateCreation(): ?\DateTimeInterface
  124.     {
  125.         return $this->date_creation;
  126.     }
  127.     public function setDateCreation(?\DateTimeInterface $date_creation): static
  128.     {
  129.         $this->date_creation $date_creation;
  130.         return $this;
  131.     }
  132.     public function __toString()
  133.     {
  134.         return $this->label// Assurez-vous que $this->name est une propriété chaîne de caractères
  135.     }
  136. }