src/Entity/Forum/Message.php line 30

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the adrec-platform package.
  4.  *
  5.  * (c) Benjamin Georgeault <https://www.pressop.eu>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace App\Entity\Forum;
  11. use App\Entity\Account\User;
  12. use App\Entity\Common\Assignable;
  13. use App\Entity\Scholar\Chapter\Chapter;
  14. use App\Entity\Scholar\Lesson\Lesson;
  15. use App\Entity\Scholar\Module\Module;
  16. use App\Entity\Scholar\Training\Training;
  17. use App\Repository\Forum\MessageRepository;
  18. use App\Validator\Constraints as AcmeAssert;
  19. use Doctrine\Common\Collections\Collection;
  20. use Doctrine\ORM\Mapping as ORM;
  21. use Symfony\Component\Validator\Constraints as Assert;
  22. #[
  23.     ORM\Entity(repositoryClassMessageRepository::class),
  24.     ORM\Table(name'forum_chapter_message'),
  25. ]
  26. class Message extends Assignable
  27. {
  28.     #[ORM\Column(type'text'nullabletrue)]
  29.     #[
  30.         Assert\NotBlank(message'scholar.forum.content.NotBlank'),
  31.         Assert\Length(
  32.             min2,
  33.             max2000,
  34.             minMessage'scholar.forum.content.Length.min',
  35.             maxMessage'scholar.forum.content.Length.max',
  36.         ),
  37.         AcmeAssert\HtmlTagConstraint(),
  38.         AcmeAssert\InjuryConstraint(message'scholar.forum.content.InjuryConstraint')
  39.     ]
  40.     private ?string $content null;
  41.     #[ORM\ManyToOne(targetEntityChapter::class, inversedBy'messages')]
  42.     #[ORM\JoinColumn(nullablefalseonDelete'CASCADE')]
  43.     private ?Chapter $chapter;
  44.     #[ORM\ManyToOne(targetEntityTraining::class)]
  45.     #[ORM\JoinColumn(nullabletrueonDelete'SET NULL')]
  46.     private ?Training $training null;
  47.     #[ORM\ManyToOne(targetEntityModule::class)]
  48.     #[ORM\JoinColumn(nullabletrueonDelete'SET NULL')]
  49.     private ?Module $module null;
  50.     #[ORM\ManyToOne(targetEntityUser::class)]
  51.     #[ORM\JoinColumn(nullabletrueonDelete'SET NULL')]
  52.     private ?User $user null;
  53.     #[ORM\OneToMany(mappedBy'parent'targetEntityMessage::class, orphanRemovaltrue)]
  54.     private $children null;
  55.     #[ORM\ManyToOne(targetEntityMessage::class, inversedBy'children')]
  56.      #[ORM\JoinColumn(nullabletrueonDelete'CASCADE')]
  57.     private $parent null;
  58.     /**
  59.      * @return string|null
  60.      */
  61.     public function getContent(): ?string
  62.     {
  63.         return $this->content;
  64.     }
  65.     /**
  66.      * @param string|null $content
  67.      */
  68.     public function setContent(?string $content): void
  69.     {
  70.         $this->content $content;
  71.     }
  72.     public function getChapter(): ?Chapter
  73.     {
  74.         return $this->chapter;
  75.     }
  76.     public function setChapter(?Chapter $chapter): self
  77.     {
  78.         $this->chapter $chapter;
  79.         return $this;
  80.     }
  81.     /**
  82.      * @return User|null
  83.      */
  84.     public function getUser(): ?User
  85.     {
  86.         return $this->user;
  87.     }
  88.     /**
  89.      * @param User|null $user
  90.      */
  91.     public function setUser(?User $user): void
  92.     {
  93.         $this->user $user;
  94.     }
  95.     /**
  96.      * @return Message[]|Collection
  97.      */
  98.     public function getChildren()
  99.     {
  100.         return $this->children;
  101.     }
  102.     /**
  103.      * @param Message[]|Collection $children
  104.      */
  105.     public function setChildren($children): void
  106.     {
  107.         $this->children $children;
  108.     }
  109.     /**
  110.      * @return Message|null
  111.      */
  112.     public function getParent(): ?Message
  113.     {
  114.         return $this->parent;
  115.     }
  116.     /**
  117.      * @param Message|null $parent
  118.      */
  119.     public function setParent(?Message $parent): void
  120.     {
  121.         $this->parent $parent;
  122.     }
  123.     public function getTraining(): ?Training
  124.     {
  125.         return $this->training;
  126.     }
  127.     public function setTraining(?Training $training): Message
  128.     {
  129.         $this->training $training;
  130.         return $this;
  131.     }
  132.     public function getModule(): ?Module
  133.     {
  134.         return $this->module;
  135.     }
  136.     public function setModule(?Module $module): Message
  137.     {
  138.         $this->module $module;
  139.         return $this;
  140.     }
  141. }