<?phpnamespace App\Entity;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Gedmo\Mapping\Annotation as Gedmo;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;/** * @ORM\Entity(repositoryClass="App\Repository\ArticleTypeRepository") * @UniqueEntity("name") */class ArticleType{ /** * @ORM\Id() * @ORM\GeneratedValue() * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string", length=255) */ private $name; /** * @Gedmo\Slug(fields={"name"}) * @ORM\Column(length=255, unique=true) */ protected $slug; /** * @ORM\OneToMany(targetEntity="App\Entity\Article", mappedBy="type") */ private $articles; public function __construct() { $this->articles = new ArrayCollection(); } public function __toString() { return $this->name; } public function getId(): ?int { return $this->id; } public function getName(): ?string { return $this->name; } public function setName(string $name): self { $this->name = $name; return $this; } /** * @return Collection|Article[] */ public function getArticles(): Collection { return $this->articles; } public function addArticle(Article $article): self { if (!$this->articles->contains($article)) { $this->articles[] = $article; $article->setType($this); } return $this; } public function removeArticle(Article $article): self { if ($this->articles->contains($article)) { $this->articles->removeElement($article); // set the owning side to null (unless already changed) if ($article->getType() === $this) { $article->setType(null); } } return $this; } public function getSlug(): ?string { return $this->slug; } public function setSlug(string $slug): self { $this->slug = $slug; return $this; }}