added Blog entity
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\SectionRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
@@ -32,6 +34,16 @@ class Section
|
||||
*/
|
||||
private $teaserImage;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity=Blog::class, mappedBy="section")
|
||||
*/
|
||||
private $blogs;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->blogs = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
@@ -72,4 +84,31 @@ class Section
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Blog[]
|
||||
*/
|
||||
public function getBlogs(): Collection
|
||||
{
|
||||
return $this->blogs;
|
||||
}
|
||||
|
||||
public function addBlog(Blog $blog): self
|
||||
{
|
||||
if (!$this->blogs->contains($blog)) {
|
||||
$this->blogs[] = $blog;
|
||||
$blog->addSection($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeBlog(Blog $blog): self
|
||||
{
|
||||
if ($this->blogs->removeElement($blog)) {
|
||||
$blog->removeSection($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user