src/Entity/Engagement/EngagementBudgetEngageComment.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Engagement;
  3. use App\Entity\User;
  4. use App\Repository\EngagementBudgetEngageCommentRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * @ORM\Entity(repositoryClass=EngagementBudgetEngageCommentRepository::class)
  10.  */
  11. class EngagementBudgetEngageComment
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\Column(type="text",  nullable=true)
  21.      */
  22.     private $comment;
  23.     /**
  24.      * @ORM\Column(type="datetime", nullable=true)
  25.      */
  26.     private $createdAt;
  27.     /**
  28.      * @ORM\ManyToOne(targetEntity="\App\Entity\User", cascade={"persist"})
  29.      * @ORM\JoinColumn(name="user_id", referencedColumnName="id",nullable=true)
  30.      */
  31.     private $user;
  32.     /**
  33.      * @ORM\ManyToOne(targetEntity="EngagementBudgetEngage",inversedBy="comment",cascade={"persist"})
  34.      * @ORM\JoinColumn(name="engagement_budget_engage_id", referencedColumnName="id",nullable=true)
  35.      */
  36.     private $engagementBudgetEngage;
  37.     /**
  38.      * Commentaire parent (réponse à un commentaire).
  39.      * @ORM\ManyToOne(targetEntity="EngagementBudgetEngageComment", inversedBy="children", cascade={"persist"})
  40.      * @ORM\JoinColumn(name="parent_id", referencedColumnName="id", nullable=true, onDelete="CASCADE")
  41.      */
  42.     private $parent;
  43.     /**
  44.      * @ORM\OneToMany(targetEntity="EngagementBudgetEngageComment", mappedBy="parent", cascade={"persist"})
  45.      * @ORM\OrderBy({"createdAt" = "ASC"})
  46.      */
  47.     private $children;
  48.     public function __construct()
  49.     {
  50.         $this->createdAt = new \DateTime();
  51.         $this->children  = new ArrayCollection();
  52.     }
  53.     public function getId(): ?int
  54.     {
  55.         return $this->id;
  56.     }
  57.     public function getComment(): ?string
  58.     {
  59.         return $this->comment;
  60.     }
  61.     public function setComment(?string $comment): self
  62.     {
  63.         $this->comment = $comment;
  64.         return $this;
  65.     }
  66.     public function getCreatedAt(): ?\DateTimeInterface
  67.     {
  68.         return $this->createdAt;
  69.     }
  70.     public function setCreatedAt(?\DateTimeInterface $createdAt): self
  71.     {
  72.         $this->createdAt = $createdAt;
  73.         return $this;
  74.     }
  75.     public function getUser(): ?User
  76.     {
  77.         return $this->user;
  78.     }
  79.     public function setUser(?User $user): self
  80.     {
  81.         $this->user = $user;
  82.         return $this;
  83.     }
  84.     public function getEngagementBudgetEngage(): ?EngagementBudgetEngage
  85.     {
  86.         return $this->engagementBudgetEngage;
  87.     }
  88.     public function setEngagementBudgetEngage(?EngagementBudgetEngage $engagementBudgetEngage): self
  89.     {
  90.         $this->engagementBudgetEngage = $engagementBudgetEngage;
  91.         return $this;
  92.     }
  93.     public function getParent(): ?self
  94.     {
  95.         return $this->parent;
  96.     }
  97.     public function setParent(?self $parent): self
  98.     {
  99.         $this->parent = $parent;
  100.         return $this;
  101.     }
  102.     /**
  103.      * @return Collection|EngagementBudgetEngageComment[]
  104.      */
  105.     public function getChildren(): Collection
  106.     {
  107.         return $this->children;
  108.     }
  109.     public function addChild(self $child): self
  110.     {
  111.         if (!$this->children->contains($child)) {
  112.             $this->children[] = $child;
  113.             $child->setParent($this);
  114.         }
  115.         return $this;
  116.     }
  117.     public function removeChild(self $child): self
  118.     {
  119.         if ($this->children->removeElement($child)) {
  120.             if ($child->getParent() === $this) {
  121.                 $child->setParent(null);
  122.             }
  123.         }
  124.         return $this;
  125.     }
  126. }