<?php
namespace App\Entity\Engagement;
use App\Entity\User;
use App\Repository\EngagementBudgetEngageCommentRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=EngagementBudgetEngageCommentRepository::class)
*/
class EngagementBudgetEngageComment
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $comment;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $createdAt;
/**
* @ORM\ManyToOne(targetEntity="\App\Entity\User", cascade={"persist"})
* @ORM\JoinColumn(name="user_id", referencedColumnName="id",nullable=true)
*/
private $user;
/**
* @ORM\ManyToOne(targetEntity="EngagementBudgetEngage",inversedBy="comment",cascade={"persist"})
* @ORM\JoinColumn(name="engagement_budget_engage_id", referencedColumnName="id",nullable=true)
*/
private $engagementBudgetEngage;
/**
* Commentaire parent (réponse à un commentaire).
* @ORM\ManyToOne(targetEntity="EngagementBudgetEngageComment", inversedBy="children", cascade={"persist"})
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id", nullable=true, onDelete="CASCADE")
*/
private $parent;
/**
* @ORM\OneToMany(targetEntity="EngagementBudgetEngageComment", mappedBy="parent", cascade={"persist"})
* @ORM\OrderBy({"createdAt" = "ASC"})
*/
private $children;
public function __construct()
{
$this->createdAt = new \DateTime();
$this->children = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getComment(): ?string
{
return $this->comment;
}
public function setComment(?string $comment): self
{
$this->comment = $comment;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(?\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getEngagementBudgetEngage(): ?EngagementBudgetEngage
{
return $this->engagementBudgetEngage;
}
public function setEngagementBudgetEngage(?EngagementBudgetEngage $engagementBudgetEngage): self
{
$this->engagementBudgetEngage = $engagementBudgetEngage;
return $this;
}
public function getParent(): ?self
{
return $this->parent;
}
public function setParent(?self $parent): self
{
$this->parent = $parent;
return $this;
}
/**
* @return Collection|EngagementBudgetEngageComment[]
*/
public function getChildren(): Collection
{
return $this->children;
}
public function addChild(self $child): self
{
if (!$this->children->contains($child)) {
$this->children[] = $child;
$child->setParent($this);
}
return $this;
}
public function removeChild(self $child): self
{
if ($this->children->removeElement($child)) {
if ($child->getParent() === $this) {
$child->setParent(null);
}
}
return $this;
}
}