src/Entity/PostComment.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Translation\AutoTranslatableTrait;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
  8. #[ORM\Table(name'post_comment')]
  9. #[ORM\Entity(repositoryClass'App\Entity\Repository\PostCommentRepository')]
  10. class PostComment implements TranslatableInterface
  11. {
  12.     use AutoTranslatableTrait;
  13.     #[ORM\Id]
  14.     #[ORM\Column(type'integer')]
  15.     #[ORM\GeneratedValue(strategy'AUTO')]
  16.     private $id;
  17.     #[ORM\Column(type'text'length0nullablefalse)]
  18.     private $text;
  19.     #[ORM\Column(type'json'nullabletrue)]
  20.     private $tags;
  21.     #[ORM\Column(type'datetime'nullablefalse)]
  22.     private $date_created;
  23.     #[ORM\OneToMany(targetEntity'App\Entity\PostComment'mappedBy'parentPostComment')]
  24.     private $childPostComment;
  25.     #[ORM\ManyToOne(targetEntity'App\Entity\Post'inversedBy'postComment')]
  26.     #[ORM\JoinColumn(name'post_id'referencedColumnName'id'nullablefalse)]
  27.     private $post;
  28.     #[ORM\ManyToOne(targetEntity'App\Entity\PostComment'inversedBy'childPostComment')]
  29.     #[ORM\JoinColumn(name'post_comment_id'referencedColumnName'id')]
  30.     private $parentPostComment;
  31.     #[ORM\ManyToOne(targetEntity'App\Entity\User'inversedBy'postComment')]
  32.     #[ORM\JoinColumn(name'user_id'referencedColumnName'id'nullablefalse)]
  33.     private $user;
  34.     #[ORM\OneToMany(targetEntityCommentLike::class, mappedBy'comment'orphanRemovaltrue)]
  35.     private $commentLikes;
  36.     #[ORM\Column(type'json'nullabletrue)]
  37.     private $richtext = [];
  38.     #[ORM\Column(type'string'length255nullabletrue)]
  39.     private $imageUrl;
  40.     #[ORM\OneToMany(targetEntityCommentTag::class, mappedBy'comment'orphanRemovaltrue)]
  41.     private $commentTags;
  42.     #[ORM\Column(length3nullabletrue)]
  43.     private ?string $language null;
  44.     #[ORM\Column(nullabletrue)]
  45.     private ?array $ai_moderation_result null;
  46.     #[ORM\Column(nullabletrue)]
  47.     private ?bool $hidden null;
  48.     #[ORM\OneToMany(mappedBy'post_comment'targetEntityPostCommentReport::class, orphanRemovaltrue)]
  49.     private Collection $postCommentReports;
  50.     public function __toString(): string
  51.     {
  52.         return 'comment_' $this->getText();
  53.     }
  54.     public function __construct()
  55.     {
  56.         $this->childPostComment = new ArrayCollection();
  57.         $this->commentLikes = new ArrayCollection();
  58.         $this->date_created = new \DateTime();
  59.         $this->commentTags = new ArrayCollection();
  60.         $this->postCommentReports = new ArrayCollection();
  61.     }
  62.     public function getId(): ?int
  63.     {
  64.         return $this->id;
  65.     }
  66.     public function getText(): ?string
  67.     {
  68.         return $this->text;
  69.     }
  70.     public function setText(string $text): self
  71.     {
  72.         $this->text $text;
  73.         return $this;
  74.     }
  75.     public function getDateCreated(): ?\DateTimeInterface
  76.     {
  77.         return $this->date_created;
  78.     }
  79.     public function setDateCreated(\DateTimeInterface $date_created): self
  80.     {
  81.         $this->date_created $date_created;
  82.         return $this;
  83.     }
  84.     /**
  85.      * @return Collection|PostComment[]
  86.      */
  87.     public function getChildPostComment(): Collection
  88.     {
  89.         return $this->childPostComment;
  90.     }
  91.     public function addChildPostComment(PostComment $childPostComment): self
  92.     {
  93.         if (!$this->childPostComment->contains($childPostComment)) {
  94.             $this->childPostComment[] = $childPostComment;
  95.             $childPostComment->setParentPostComment($this);
  96.         }
  97.         return $this;
  98.     }
  99.     public function removeChildPostComment(PostComment $childPostComment): self
  100.     {
  101.         if ($this->childPostComment->contains($childPostComment)) {
  102.             $this->childPostComment->removeElement($childPostComment);
  103.             // set the owning side to null (unless already changed)
  104.             if ($childPostComment->getParentPostComment() === $this) {
  105.                 $childPostComment->setParentPostComment(null);
  106.             }
  107.         }
  108.         return $this;
  109.     }
  110.     public function getPost(): ?Post
  111.     {
  112.         return $this->post;
  113.     }
  114.     public function setPost(?Post $post): self
  115.     {
  116.         $this->post $post;
  117.         return $this;
  118.     }
  119.     public function getParentPostComment(): ?self
  120.     {
  121.         return $this->parentPostComment;
  122.     }
  123.     public function setParentPostComment(?self $parentPostComment): self
  124.     {
  125.         $this->parentPostComment $parentPostComment;
  126.         return $this;
  127.     }
  128.     public function getUser(): ?User
  129.     {
  130.         return $this->user;
  131.     }
  132.     public function setUser(?User $user): self
  133.     {
  134.         $this->user $user;
  135.         return $this;
  136.     }
  137.     public function getTags(): ?array
  138.     {
  139.         return $this->tags;
  140.     }
  141.     public function setTags(?array $tags): self
  142.     {
  143.         $this->tags $tags;
  144.         return $this;
  145.     }
  146.     /**
  147.      * @return Collection|CommentLike[]
  148.      */
  149.     public function getCommentLikes(): Collection
  150.     {
  151.         return $this->commentLikes;
  152.     }
  153.     public function addCommentLike(CommentLike $commentLike): self
  154.     {
  155.         if (!$this->commentLikes->contains($commentLike)) {
  156.             $this->commentLikes[] = $commentLike;
  157.             $commentLike->setComment($this);
  158.         }
  159.         return $this;
  160.     }
  161.     public function removeCommentLike(CommentLike $commentLike): self
  162.     {
  163.         if ($this->commentLikes->removeElement($commentLike)) {
  164.             // set the owning side to null (unless already changed)
  165.             if ($commentLike->getComment() === $this) {
  166.                 $commentLike->setComment(null);
  167.             }
  168.         }
  169.         return $this;
  170.     }
  171.     public function getRichtext(bool $skipTranslation false): ?array
  172.     {
  173.         if ($skipTranslation || $this->shouldNotBeTranslated()) {
  174.             return $this->richtext;
  175.         }
  176.         $translated $this->translate()->getRichtext();
  177.         return !empty($translated) ? $translated $this->richtext;
  178.     }
  179.     public function setRichtext(?array $richtext): self
  180.     {
  181.         $this->richtext $richtext;
  182.         return $this;
  183.     }
  184.     public function getImageUrl(): ?string
  185.     {
  186.         return $this->imageUrl;
  187.     }
  188.     public function setImageUrl(?string $imageUrl): self
  189.     {
  190.         $this->imageUrl $imageUrl;
  191.         return $this;
  192.     }
  193.     /**
  194.      * @return Collection<int, CommentTag>
  195.      */
  196.     public function getCommentTags(): Collection
  197.     {
  198.         return $this->commentTags;
  199.     }
  200.     public function addCommentTag(CommentTag $commentTag): self
  201.     {
  202.         if (!$this->commentTags->contains($commentTag)) {
  203.             $this->commentTags[] = $commentTag;
  204.             $commentTag->setComment($this);
  205.         }
  206.         return $this;
  207.     }
  208.     public function removeCommentTag(CommentTag $commentTag): self
  209.     {
  210.         if ($this->commentTags->removeElement($commentTag)) {
  211.             // set the owning side to null (unless already changed)
  212.             if ($commentTag->getComment() === $this) {
  213.                 $commentTag->setComment(null);
  214.             }
  215.         }
  216.         return $this;
  217.     }
  218.     public function getLanguage(): ?string
  219.     {
  220.         return $this->language;
  221.     }
  222.     public function setLanguage(?string $language): static
  223.     {
  224.         $this->language $language;
  225.         return $this;
  226.     }
  227.     public function getAiModerationResult(): ?array
  228.     {
  229.         return $this->ai_moderation_result;
  230.     }
  231.     public function setAiModerationResult(?array $ai_moderation_result): static
  232.     {
  233.         $this->ai_moderation_result $ai_moderation_result;
  234.         return $this;
  235.     }
  236.     public function isHidden(): ?bool
  237.     {
  238.         return $this->hidden;
  239.     }
  240.     public function setHidden(?bool $hidden): static
  241.     {
  242.         $this->hidden $hidden;
  243.         return $this;
  244.     }
  245.     /**
  246.      * @return Collection<int, PostCommentReport>
  247.      */
  248.     public function getPostCommentReports(): Collection
  249.     {
  250.         return $this->postCommentReports;
  251.     }
  252.     public function addPostCommentReport(PostCommentReport $postCommentReport): static
  253.     {
  254.         if (!$this->postCommentReports->contains($postCommentReport)) {
  255.             $this->postCommentReports->add($postCommentReport);
  256.             $postCommentReport->setPostComment($this);
  257.         }
  258.         return $this;
  259.     }
  260.     public function removePostCommentReport(PostCommentReport $postCommentReport): static
  261.     {
  262.         if ($this->postCommentReports->removeElement($postCommentReport)) {
  263.             // set the owning side to null (unless already changed)
  264.             if ($postCommentReport->getPostComment() === $this) {
  265.                 $postCommentReport->setPostComment(null);
  266.             }
  267.         }
  268.         return $this;
  269.     }
  270. }