<?phpnamespace App\Entity;use ApiPlatform\Core\Annotation\ApiResource;use App\Repository\LangueRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Serializer\Annotation\Groups;use Symfony\Component\Validator\Constraints as Assert;#[ORM\Entity(repositoryClass: LangueRepository::class)]/*#[ApiResource( normalizationContext: ['groups' => ['profile']], denormalizationContext: ['groups' => ['profile']],)]*/class Langue{ #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] #[Groups("profile")] private ?int $id = null; #[ORM\Column(length: 255, nullable: true)] #[Assert\NotBlank] #[Groups("profile")] private ?string $title = null; #[ORM\ManyToMany(targetEntity: Profile::class, mappedBy: 'langues')] private Collection $profiles; #[ORM\OneToMany(mappedBy: 'langue', targetEntity: LangueTranslation::class, cascade: ["persist"])] #[Groups("profile")] private Collection $translations; public function __construct() { $this->profiles = new ArrayCollection(); $this->translations = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getTitle(): ?string { return $this->title; } public function setTitle(?string $title): self { $this->title = $title; return $this; } /** * @return Collection<int, Profile> */ public function getProfiles(): Collection { return $this->profiles; } public function addProfile(Profile $profile): self { if (!$this->profiles->contains($profile)) { $this->profiles->add($profile); $profile->addLangue($this); } return $this; } public function removeProfile(Profile $profile): self { if ($this->profiles->removeElement($profile)) { $profile->removeLangue($this); } return $this; } public function __toString() { return $this->title; } /** * @return Collection<int, LangueTranslation> */ public function getTranslations(): Collection { return $this->translations; } public function addTranslation(LangueTranslation $translation): self { if (!$this->translations->contains($translation)) { $this->translations->add($translation); $translation->setLangue($this); } return $this; } public function removeTranslation(LangueTranslation $translation): self { if ($this->translations->removeElement($translation)) { // set the owning side to null (unless already changed) if ($translation->getLangue() === $this) { $translation->setLangue(null); } } return $this; } }