<?php
namespace App\Entity;
use App\Repository\BlogTagRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=BlogTagRepository::class)
*/
class BlogTag implements TagEntityInterface
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\Column(type="string", length=255, unique=true)
*/
private $slug;
/**
* @ORM\ManyToMany(targetEntity=BlogPost::class, mappedBy="tags")
*/
private $blogPosts;
public function __construct()
{
$this->blogPosts = new ArrayCollection();
}
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;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
/**
* @return Collection<int, BlogPost>
*/
public function getBlogPosts(): Collection
{
return $this->blogPosts;
}
public function addBlogPost(BlogPost $blogPost): self
{
if (!$this->blogPosts->contains($blogPost)) {
$this->blogPosts[] = $blogPost;
$blogPost->addTag($this);
}
return $this;
}
public function removeBlogPost(BlogPost $blogPost): self
{
if ($this->blogPosts->removeElement($blogPost)) {
$blogPost->removeTag($this);
}
return $this;
}
//public function
}