src/Entity/Competence.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CompetenceRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassCompetenceRepository::class)]
  8. class Competence
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column]
  13.     private ?int $id null;
  14.     #[ORM\Column(length255)]
  15.     private ?string $libelle null;
  16.     #[ORM\ManyToOne(targetEntityself::class, inversedBy'refSousCompetences')]
  17.     private ?self $refCompetence null;
  18.     #[ORM\OneToMany(mappedBy'refCompetence'targetEntityself::class)]
  19.     private Collection $refSousCompetences;
  20.     #[ORM\Column(length20)]
  21.     private ?string $code null;
  22.     #[ORM\ManyToMany(targetEntitySavoirTechnologique::class, mappedBy'refCompetences')]
  23.     private Collection $refSavoirTechnologiques;
  24.     #[ORM\ManyToMany(targetEntitySequence::class, mappedBy'refCompetence')]
  25.     private Collection $refSequences;
  26.     public function __construct()
  27.     {
  28.         $this->refSousCompetences = new ArrayCollection();
  29.         $this->refSavoirTechnologiques = new ArrayCollection();
  30.         $this->refSequences = new ArrayCollection();
  31.     }
  32.     public function getId(): ?int
  33.     {
  34.         return $this->id;
  35.     }
  36.     public function getLibelle(): ?string
  37.     {
  38.         return $this->libelle;
  39.     }
  40.     public function setLibelle(string $libelle): self
  41.     {
  42.         $this->libelle $libelle;
  43.         return $this;
  44.     }
  45.     public function getRefCompetence(): ?self
  46.     {
  47.         return $this->refCompetence;
  48.     }
  49.     public function setRefCompetence(?self $refCompetence): self
  50.     {
  51.         $this->refCompetence $refCompetence;
  52.         return $this;
  53.     }
  54.     /**
  55.      * @return Collection<int, self>
  56.      */
  57.     public function getRefSousCompetences(): Collection
  58.     {
  59.         return $this->refSousCompetences;
  60.     }
  61.     public function addRefSousCompetence(self $refSousCompetence): self
  62.     {
  63.         if (!$this->refSousCompetences->contains($refSousCompetence)) {
  64.             $this->refSousCompetences->add($refSousCompetence);
  65.             $refSousCompetence->setRefCompetence($this);
  66.         }
  67.         return $this;
  68.     }
  69.     public function removeRefSousCompetence(self $refSousCompetence): self
  70.     {
  71.         if ($this->refSousCompetences->removeElement($refSousCompetence)) {
  72.             // set the owning side to null (unless already changed)
  73.             if ($refSousCompetence->getRefCompetence() === $this) {
  74.                 $refSousCompetence->setRefCompetence(null);
  75.             }
  76.         }
  77.         return $this;
  78.     }
  79.     public function getCode(): ?string
  80.     {
  81.         return $this->code;
  82.     }
  83.     public function setCode(string $code): self
  84.     {
  85.         $this->code $code;
  86.         return $this;
  87.     }
  88.     /**
  89.      * @return Collection<int, SavoirTechnologique>
  90.      */
  91.     public function getRefSavoirTechnologiques(): Collection
  92.     {
  93.         return $this->refSavoirTechnologiques;
  94.     }
  95.     public function addRefSavoirTechnologique(SavoirTechnologique $refSavoirTechnologique): self
  96.     {
  97.         if (!$this->refSavoirTechnologiques->contains($refSavoirTechnologique)) {
  98.             $this->refSavoirTechnologiques->add($refSavoirTechnologique);
  99.             $refSavoirTechnologique->addRefCompetence($this);
  100.         }
  101.         return $this;
  102.     }
  103.     public function removeRefSavoirTechnologique(SavoirTechnologique $refSavoirTechnologique): self
  104.     {
  105.         if ($this->refSavoirTechnologiques->removeElement($refSavoirTechnologique)) {
  106.             $refSavoirTechnologique->removeRefCompetence($this);
  107.         }
  108.         return $this;
  109.     }
  110.     public function __toString(): string
  111.     {
  112.         return "[".$this->getCode()."] ".$this->getLibelle();// TODO: Implement __toString() method.
  113.     }
  114.     public function getMainCompetence(): Competence {
  115.         return (is_null($this->getRefCompetence()))? $this $this->getRefCompetence()->getMainCompetence();
  116.     }
  117.     /**
  118.      * @return Collection<int, Sequence>
  119.      */
  120.     public function getRefSequences(): Collection
  121.     {
  122.         return $this->refSequences;
  123.     }
  124.     public function addRefSequence(Sequence $refSequence): self
  125.     {
  126.         if (!$this->refSequences->contains($refSequence)) {
  127.             $this->refSequences->add($refSequence);
  128.             $refSequence->addRefCompetence($this);
  129.         }
  130.         return $this;
  131.     }
  132.     public function removeRefSequence(Sequence $refSequence): self
  133.     {
  134.         if ($this->refSequences->removeElement($refSequence)) {
  135.             $refSequence->removeRefCompetence($this);
  136.         }
  137.         return $this;
  138.     }
  139. }