src/Entity/CommentEquipementProjet.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CommentEquipementProjetRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=CommentEquipementProjetRepository::class)
  9.  */
  10. class CommentEquipementProjet
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="text")
  20.      */
  21.     private $comment;
  22.     /**
  23.      * @ORM\Column(type="datetime")
  24.      */
  25.     private $createdAt;
  26.     /**
  27.      * @ORM\ManyToOne(targetEntity=User::class)
  28.      */
  29.     private $user;
  30.     /**
  31.      * @ORM\ManyToOne(targetEntity=Project::class, inversedBy="commentEquipementProjets")
  32.      */
  33.     private $projet;
  34.     /**
  35.      * @ORM\ManyToOne(targetEntity=CommentEquipementProjet::class, inversedBy="replies")
  36.      * @ORM\JoinColumn(name="parent_id", referencedColumnName="id", nullable=true, onDelete="CASCADE")
  37.      */
  38.     private $parent;
  39.     /**
  40.      * @ORM\OneToMany(
  41.      *     targetEntity=CommentEquipementProjet::class,
  42.      *     mappedBy="parent",
  43.      *     cascade={"persist", "remove"}
  44.     )
  45.      * @ORM\OrderBy({"createdAt" = "ASC"})
  46.      */
  47.     private $replies;
  48.     public function __construct()
  49.     {
  50.         $this->createdAt = new \DateTime();
  51.         $this->replies = 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.     /**
  85.      * @return mixed
  86.      */
  87.     public function getProjet()
  88.     {
  89.         return $this->projet;
  90.     }
  91.     /**
  92.      * @param mixed $projet
  93.      */
  94.     public function setProjet($projet): void
  95.     {
  96.         $this->projet = $projet;
  97.     }
  98.     public function getParent(): ?self
  99.     {
  100.         return $this->parent;
  101.     }
  102.     public function setParent(?self $parent): self
  103.     {
  104.         $this->parent = $parent;
  105.         return $this;
  106.     }
  107.     public function getReplies()
  108.     {
  109.         return $this->replies;
  110.     }
  111.     public function addReply(self $reply): self
  112.     {
  113.         if (!$this->replies->contains($reply)) {
  114.             $this->replies[] = $reply;
  115.             $reply->setParent($this);
  116.         }
  117.         return $this;
  118.     }
  119.     public function removeReply(self $reply): self
  120.     {
  121.         if ($this->replies->removeElement($reply)) {
  122.             if ($reply->getParent() === $this) {
  123.                 $reply->setParent(null);
  124.             }
  125.         }
  126.         return $this;
  127.     }
  128. }