deblan.io-murph/src/Entity/Blog/Comment.php

191 lines
3.6 KiB
PHP

<?php
namespace App\Entity\Blog;
use App\Core\Doctrine\Timestampable;
use App\Repository\Blog\CommentRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use App\Core\Entity\EntityInterface;
/**
* @ORM\Entity(repositoryClass=CommentRepository::class)
*/
class Comment implements EntityInterface
{
use Timestampable;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $author;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $website;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $email;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $content;
/**
* @ORM\Column(type="boolean")
*/
private $isActive;
/**
* @ORM\ManyToOne(targetEntity=Post::class, inversedBy="comments")
* @ORM\JoinColumn(nullable=false)
*/
private $post;
/**
* @ORM\ManyToOne(targetEntity=Comment::class, inversedBy="comments")
*/
private $parentComment;
/**
* @ORM\OneToMany(targetEntity=Comment::class, mappedBy="parentComment")
*/
private $comments;
public function __construct()
{
$this->comments = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getAuthor(): ?string
{
return $this->author;
}
public function setAuthor(string $author): self
{
$this->author = $author;
return $this;
}
public function getWebsite(): ?string
{
return $this->website;
}
public function setWebsite(?string $website): self
{
$this->website = $website;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(?string $content): self
{
$this->content = $content;
return $this;
}
public function getIsActive(): ?bool
{
return $this->isActive;
}
public function setIsActive(bool $isActive): self
{
$this->isActive = $isActive;
return $this;
}
public function getPost(): ?Post
{
return $this->post;
}
public function setPost(?Post $post): self
{
$this->post = $post;
return $this;
}
public function getParentComment(): ?self
{
return $this->parentComment;
}
public function setParentComment(?self $parentComment): self
{
$this->parentComment = $parentComment;
return $this;
}
/**
* @return Collection|self[]
*/
public function getComments(): Collection
{
return $this->comments;
}
public function addComment(self $comment): self
{
if (!$this->comments->contains($comment)) {
$this->comments[] = $comment;
$comment->setParentComment($this);
}
return $this;
}
public function removeComment(self $comment): self
{
if ($this->comments->removeElement($comment)) {
// set the owning side to null (unless already changed)
if ($comment->getParentComment() === $this) {
$comment->setParentComment(null);
}
}
return $this;
}
}