src\Entity\UserSurveyComment.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserSurveyCommentRepository;
  4. use DateTime;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * @ORM\Entity(repositoryClass=UserSurveyCommentRepository::class)
  10.  */
  11. class UserSurveyComment
  12. {
  13.     public const TYPES = [
  14.         'problem' => 'Problème',
  15.         'resolution' => 'Résolution du problème',
  16.         'CMU' => "demande de CMU"
  17.     ];
  18.     /**
  19.      * @ORM\Id
  20.      * @ORM\GeneratedValue
  21.      * @ORM\Column(type="integer")
  22.      */
  23.     private $id;
  24.     /**
  25.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="userSurveyComments")
  26.      * @ORM\JoinColumn(nullable=false)
  27.      */
  28.     private $user;
  29.     /**
  30.      * @ORM\ManyToOne(targetEntity=UserSurvey::class, inversedBy="userSurveyComments")
  31.      * @ORM\JoinColumn(nullable=false)
  32.      */
  33.     private $userSurvey;
  34.     /**
  35.      * @ORM\Column(type="datetime")
  36.      */
  37.     private $dateAdd;
  38.     /**
  39.      * @ORM\Column(type="datetime")
  40.      */
  41.     private $dateUpdate;
  42.     /**
  43.      * @ORM\Column(type="string", length=5000, nullable=true)
  44.      */
  45.     private $Comment;
  46.     /**
  47.      * @ORM\Column(type="boolean")
  48.      */
  49.     private $isArchived false;
  50.     /**
  51.      * @ORM\ManyToOne(targetEntity=UserSurveyComment::class, inversedBy="replies")
  52.      */
  53.     private $replyTo;
  54.     /**
  55.      * @ORM\OneToMany(targetEntity=UserSurveyComment::class, mappedBy="replyTo", orphanRemoval=true, cascade={"all"})
  56.      */
  57.     private $replies;
  58.     /**
  59.      * @ORM\Column(type="string", length=255, nullable=true)
  60.      */
  61.     private $type;
  62.     public function __construct()
  63.     {
  64.         $this->setDateAdd(new DateTime());
  65.         $this->setDateUpdate(new DateTime());
  66.         $this->replies = new ArrayCollection();
  67.     }
  68.     public function getId(): ?int
  69.     {
  70.         return $this->id;
  71.     }
  72.     public function getUser(): ?User
  73.     {
  74.         return $this->user;
  75.     }
  76.     public function setUser(?User $user): self
  77.     {
  78.         $this->user $user;
  79.         return $this;
  80.     }
  81.     public function getUserSurvey(): ?UserSurvey
  82.     {
  83.         return $this->userSurvey;
  84.     }
  85.     public function setUserSurvey(?UserSurvey $userSurvey): self
  86.     {
  87.         $this->userSurvey $userSurvey;
  88.         return $this;
  89.     }
  90.     public function getDateAdd(): ?\DateTimeInterface
  91.     {
  92.         return $this->dateAdd;
  93.     }
  94.     public function setDateAdd(\DateTimeInterface $dateAdd): self
  95.     {
  96.         $this->dateAdd $dateAdd;
  97.         return $this;
  98.     }
  99.     public function getDateUpdate(): ?\DateTimeInterface
  100.     {
  101.         return $this->dateUpdate;
  102.     }
  103.     public function setDateUpdate(\DateTimeInterface $dateUpdate): self
  104.     {
  105.         $this->dateUpdate $dateUpdate;
  106.         return $this;
  107.     }
  108.     public function getComment(): ?string
  109.     {
  110.         return $this->Comment;
  111.     }
  112.     public function setComment(string $Comment): self
  113.     {
  114.         $this->Comment $Comment;
  115.         return $this;
  116.     }
  117.     /**
  118.      * @return Collection<int, self>
  119.      */
  120.     public function getReplies(): Collection
  121.     {
  122.         return $this->replies;
  123.     }
  124.     public function addReply(self $reply): self
  125.     {
  126.         if (!$this->replies->contains($reply)) {
  127.             $this->replies[] = $reply;
  128.             $reply->setReplyTo($this);
  129.         }
  130.         return $this;
  131.     }
  132.     public function removeReply(self $reply): self
  133.     {
  134.         if ($this->replies->removeElement($reply)) {
  135.             // set the owning side to null (unless already changed)
  136.             if ($reply->getReplyTo() === $this) {
  137.                 $reply->setReplyTo(null);
  138.             }
  139.         }
  140.         return $this;
  141.     }
  142.     public function getReplyTo(): ?self
  143.     {
  144.         return $this->replyTo;
  145.     }
  146.     public function setReplyTo(?self $replyTo): self
  147.     {
  148.         $this->replyTo $replyTo;
  149.         return $this;
  150.     }
  151.     /**
  152.      * @return Collection<int, self>
  153.      */
  154.     public function getNotArchivedReplies(): Collection
  155.     {
  156.         $notArchivedComments = [];
  157.         foreach ($this->replies as $comment) {
  158.             if (true !== $comment->getIsArchived()) {
  159.                 $notArchivedComments[] = $comment;
  160.             }
  161.         }
  162.         return new ArrayCollection($notArchivedComments);
  163.     }
  164.     public function getIsArchived(): ?bool
  165.     {
  166.         return $this->isArchived;
  167.     }
  168.     public function setIsArchived(bool $isArchived): self
  169.     {
  170.         $this->isArchived $isArchived;
  171.         return $this;
  172.     }
  173.     public function getTypeLabel(): string
  174.     {
  175.         if (array_key_exists($this->getType(), self::TYPES)) {
  176.             return self::TYPES[$this->getType()];
  177.         }
  178.         return '';
  179.     }
  180.     public function getType(): ?string
  181.     {
  182.         return $this->type;
  183.     }
  184.     public function setType(?string $type): self
  185.     {
  186.         if (in_array($typearray_keys(self::TYPES))) {
  187.             $this->type $type;
  188.         }
  189.         return $this;
  190.     }
  191. }