<?phpnamespace App\Entity;use App\Repository\CompetenceRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: CompetenceRepository::class)]class Competence{ #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null; #[ORM\Column(length: 255)] private ?string $libelle = null; #[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'refSousCompetences')] private ?self $refCompetence = null; #[ORM\OneToMany(mappedBy: 'refCompetence', targetEntity: self::class)] private Collection $refSousCompetences; #[ORM\Column(length: 20)] private ?string $code = null; #[ORM\ManyToMany(targetEntity: SavoirTechnologique::class, mappedBy: 'refCompetences')] private Collection $refSavoirTechnologiques; #[ORM\ManyToMany(targetEntity: Sequence::class, mappedBy: 'refCompetence')] private Collection $refSequences; public function __construct() { $this->refSousCompetences = new ArrayCollection(); $this->refSavoirTechnologiques = new ArrayCollection(); $this->refSequences = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getLibelle(): ?string { return $this->libelle; } public function setLibelle(string $libelle): self { $this->libelle = $libelle; return $this; } public function getRefCompetence(): ?self { return $this->refCompetence; } public function setRefCompetence(?self $refCompetence): self { $this->refCompetence = $refCompetence; return $this; } /** * @return Collection<int, self> */ public function getRefSousCompetences(): Collection { return $this->refSousCompetences; } public function addRefSousCompetence(self $refSousCompetence): self { if (!$this->refSousCompetences->contains($refSousCompetence)) { $this->refSousCompetences->add($refSousCompetence); $refSousCompetence->setRefCompetence($this); } return $this; } public function removeRefSousCompetence(self $refSousCompetence): self { if ($this->refSousCompetences->removeElement($refSousCompetence)) { // set the owning side to null (unless already changed) if ($refSousCompetence->getRefCompetence() === $this) { $refSousCompetence->setRefCompetence(null); } } return $this; } public function getCode(): ?string { return $this->code; } public function setCode(string $code): self { $this->code = $code; return $this; } /** * @return Collection<int, SavoirTechnologique> */ public function getRefSavoirTechnologiques(): Collection { return $this->refSavoirTechnologiques; } public function addRefSavoirTechnologique(SavoirTechnologique $refSavoirTechnologique): self { if (!$this->refSavoirTechnologiques->contains($refSavoirTechnologique)) { $this->refSavoirTechnologiques->add($refSavoirTechnologique); $refSavoirTechnologique->addRefCompetence($this); } return $this; } public function removeRefSavoirTechnologique(SavoirTechnologique $refSavoirTechnologique): self { if ($this->refSavoirTechnologiques->removeElement($refSavoirTechnologique)) { $refSavoirTechnologique->removeRefCompetence($this); } return $this; } public function __toString(): string { return "[".$this->getCode()."] ".$this->getLibelle();// TODO: Implement __toString() method. } public function getMainCompetence(): Competence { return (is_null($this->getRefCompetence()))? $this : $this->getRefCompetence()->getMainCompetence(); } /** * @return Collection<int, Sequence> */ public function getRefSequences(): Collection { return $this->refSequences; } public function addRefSequence(Sequence $refSequence): self { if (!$this->refSequences->contains($refSequence)) { $this->refSequences->add($refSequence); $refSequence->addRefCompetence($this); } return $this; } public function removeRefSequence(Sequence $refSequence): self { if ($this->refSequences->removeElement($refSequence)) { $refSequence->removeRefCompetence($this); } return $this; }}