src/Entity/News.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\Timestampable;
  4. use App\Repository\NewsRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use JMS\Serializer\Annotation\Groups;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. #[ORM\Table(name"news")]
  12. #[ORM\Index(columns: ["title","content"], name"news_index",flags: ['fulltext'])]
  13. #[ORM\HasLifecycleCallbacks]
  14. #[ORM\Entity(repositoryClassNewsRepository::class)]
  15. class News
  16. {
  17.     use Timestampable;
  18.     #[ORM\Id]
  19.     #[ORM\GeneratedValue]
  20.     #[ORM\Column]
  21.     #[Groups(['getNews','getNewsSearch'])]
  22.     private ?int $id null;
  23.     #[ORM\Column(length255)]
  24.     #[Groups(['getNews','getNewsSearch'])]
  25.     private ?string $title null;
  26.     #[ORM\Column(typeTypes::TEXT)]
  27.     #[Groups(['getNews','getNewsSearch'])]
  28.     private ?string $content null;
  29.     #[ORM\ManyToOne(inversedBy'news'cascade: ["persist"])]
  30.     #[Groups(['getNews','getNewsSearch'])]
  31.     private ?NewsCategory $newsCategory null;
  32.     #[Groups(['getNews'])]
  33.     #[ORM\OneToMany(mappedBy'news'targetEntityNewsGalerie::class,cascade: ["persist"])]
  34.     private Collection $newsGaleries;
  35.     #[Groups(['getNews','getNewsSearch'])]
  36.     #[ORM\Column(length255nullabletrue)]
  37.     private ?string $cover null;
  38.     #[ORM\ManyToOne(inversedBy'news'cascade: ["persist"])]
  39.     private ?User $author null;
  40.     #[ORM\Column(nullabletrue)]
  41.     #[Groups(['getNews'])]
  42.     private ?bool $dropdownOpen null;
  43.     #[ORM\ManyToOne(inversedBy'newsEdited'cascade: ["persist"])]
  44.     private ?User $editor null;
  45.     #[ORM\ManyToOne(inversedBy'news'cascade: ["persist"])]
  46.     private ?School $school null;
  47.     #[ORM\OneToMany(mappedBy'news'targetEntityNewsBookmark::class)]
  48.     private Collection $newsBookmarks;
  49.     #[ORM\ManyToOne(inversedBy'news')]
  50.     private ?SchoolYear $year null;
  51.     public function __construct()
  52.     {
  53.         $this->newsGaleries = new ArrayCollection();
  54.         $this->newsBookmarks = new ArrayCollection();
  55.     }
  56.     public function getId(): ?int
  57.     {
  58.         return $this->id;
  59.     }
  60.     public function getTitle(): ?string
  61.     {
  62.         return $this->title;
  63.     }
  64.     public function setTitle(string $title): static
  65.     {
  66.         $this->title $title;
  67.         return $this;
  68.     }
  69.     public function getContent(): ?string
  70.     {
  71.         return $this->content;
  72.     }
  73.     public function setContent(string $content): static
  74.     {
  75.         $this->content $content;
  76.         return $this;
  77.     }
  78.     public function getNewsCategory(): ?NewsCategory
  79.     {
  80.         return $this->newsCategory;
  81.     }
  82.     public function setNewsCategory(?NewsCategory $newsCategory): static
  83.     {
  84.         $this->newsCategory $newsCategory;
  85.         return $this;
  86.     }
  87.     /**
  88.      * @return Collection<int, NewsGalerie>
  89.      */
  90.     public function getNewsGaleries(): Collection
  91.     {
  92.         return $this->newsGaleries;
  93.     }
  94.     public function addNewsGalery(NewsGalerie $newsGalery): static
  95.     {
  96.         if (!$this->newsGaleries->contains($newsGalery)) {
  97.             $this->newsGaleries->add($newsGalery);
  98.             $newsGalery->setNews($this);
  99.         }
  100.         return $this;
  101.     }
  102.     public function removeNewsGalery(NewsGalerie $newsGalery): static
  103.     {
  104.         if ($this->newsGaleries->removeElement($newsGalery)) {
  105.             // set the owning side to null (unless already changed)
  106.             if ($newsGalery->getNews() === $this) {
  107.                 $newsGalery->setNews(null);
  108.             }
  109.         }
  110.         return $this;
  111.     }
  112.     public function getCover(): ?string
  113.     {
  114.         return $this->cover;
  115.     }
  116.     public function setCover(?string $cover): static
  117.     {
  118.         $this->cover $cover;
  119.         return $this;
  120.     }
  121.     public function getAuthor(): ?User
  122.     {
  123.         return $this->author;
  124.     }
  125.     public function setAuthor(?User $author): static
  126.     {
  127.         $this->author $author;
  128.         return $this;
  129.     }
  130.     public function isDropdownOpen(): ?bool
  131.     {
  132.         return $this->dropdownOpen;
  133.     }
  134.     public function setDropdownOpen(?bool $dropdownOpen): static
  135.     {
  136.         $this->dropdownOpen $dropdownOpen;
  137.         return $this;
  138.     }
  139.     public function getEditor(): ?User
  140.     {
  141.         return $this->editor;
  142.     }
  143.     public function setEditor(?User $editor): static
  144.     {
  145.         $this->editor $editor;
  146.         return $this;
  147.     }
  148.     public function getSchool(): ?School
  149.     {
  150.         return $this->school;
  151.     }
  152.     public function setSchool(?School $school): static
  153.     {
  154.         $this->school $school;
  155.         return $this;
  156.     }
  157.     /**
  158.      * @return Collection<int, NewsBookmark>
  159.      */
  160.     public function getNewsBookmarks(): Collection
  161.     {
  162.         return $this->newsBookmarks;
  163.     }
  164.     public function addNewsBookmark(NewsBookmark $newsBookmark): static
  165.     {
  166.         if (!$this->newsBookmarks->contains($newsBookmark)) {
  167.             $this->newsBookmarks->add($newsBookmark);
  168.             $newsBookmark->setNews($this);
  169.         }
  170.         return $this;
  171.     }
  172.     public function removeNewsBookmark(NewsBookmark $newsBookmark): static
  173.     {
  174.         if ($this->newsBookmarks->removeElement($newsBookmark)) {
  175.             // set the owning side to null (unless already changed)
  176.             if ($newsBookmark->getNews() === $this) {
  177.                 $newsBookmark->setNews(null);
  178.             }
  179.         }
  180.         return $this;
  181.     }
  182.     public function getYear(): ?SchoolYear
  183.     {
  184.         return $this->year;
  185.     }
  186.     public function setYear(?SchoolYear $year): static
  187.     {
  188.         $this->year $year;
  189.         return $this;
  190.     }
  191. }