<?php
namespace App\Entity;
use App\Repository\ObjectCommentRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ObjectCommentRepository::class)]
class ObjectComment
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 50)]
private $reference_type;
#[ORM\Column(type: 'integer')]
private $reference_id;
#[ORM\Column(type: 'text')]
private $text;
#[ORM\Column(type: 'json')]
private $richtext = [];
#[ORM\Column(type: 'datetime')]
private $created_at;
#[ORM\Column(type: 'datetime', nullable: true)]
private $updated_at;
#[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'objectComments')]
#[ORM\JoinColumn(nullable: false)]
private $user;
#[ORM\ManyToOne(targetEntity: ObjectComment::class, inversedBy: 'objectComments')]
private $parent_comment;
#[ORM\OneToMany(targetEntity: ObjectComment::class, mappedBy: 'parent_comment')]
private $objectComments;
public function __construct()
{
$this->objectComments = new ArrayCollection();
$this->created_at = new \DateTime();
}
public function getId(): ?int
{
return $this->id;
}
public function getReferenceType(): ?string
{
return $this->reference_type;
}
public function setReferenceType(string $reference_type): self
{
$this->reference_type = $reference_type;
return $this;
}
public function getReferenceId(): ?int
{
return $this->reference_id;
}
public function setReferenceId(int $reference_id): self
{
$this->reference_id = $reference_id;
return $this;
}
public function getText(): ?string
{
return $this->text;
}
public function setText(string $text): self
{
$this->text = $text;
return $this;
}
public function getRichtext(): ?array
{
return $this->richtext;
}
public function setRichtext(array $richtext): self
{
$this->richtext = $richtext;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->created_at;
}
public function setCreatedAt(\DateTimeInterface $created_at): self
{
$this->created_at = $created_at;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updated_at;
}
public function setUpdatedAt(?\DateTimeInterface $updated_at): self
{
$this->updated_at = $updated_at;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getParentComment(): ?self
{
return $this->parent_comment;
}
public function setParentComment(?self $parent_comment): self
{
$this->parent_comment = $parent_comment;
return $this;
}
/**
* @return Collection<int, self>
*/
public function getObjectComments(): Collection
{
return $this->objectComments;
}
public function addObjectComment(self $objectComment): self
{
if (!$this->objectComments->contains($objectComment)) {
$this->objectComments[] = $objectComment;
$objectComment->setParentComment($this);
}
return $this;
}
public function removeObjectComment(self $objectComment): self
{
if ($this->objectComments->removeElement($objectComment)) {
// set the owning side to null (unless already changed)
if ($objectComment->getParentComment() === $this) {
$objectComment->setParentComment(null);
}
}
return $this;
}
}