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.     #[Groups(['getNews','getNewsSearch'])]
  51.     private ?SchoolYear $year null;
  52.     public function __construct()
  53.     {
  54.         $this->newsGaleries = new ArrayCollection();
  55.         $this->newsBookmarks = new ArrayCollection();
  56.     }
  57.     public function getId(): ?int
  58.     {
  59.         return $this->id;
  60.     }
  61.     public function getTitle(): ?string
  62.     {
  63.         return $this->title;
  64.     }
  65.     public function setTitle(string $title): static
  66.     {
  67.         $this->title $title;
  68.         return $this;
  69.     }
  70.     public function getContent(): ?string
  71.     {
  72.         return $this->content;
  73.     }
  74.     public function setContent(string $content): static
  75.     {
  76.         $this->content $content;
  77.         return $this;
  78.     }
  79.     public function getNewsCategory(): ?NewsCategory
  80.     {
  81.         return $this->newsCategory;
  82.     }
  83.     public function setNewsCategory(?NewsCategory $newsCategory): static
  84.     {
  85.         $this->newsCategory $newsCategory;
  86.         return $this;
  87.     }
  88.     /**
  89.      * @return Collection<int, NewsGalerie>
  90.      */
  91.     public function getNewsGaleries(): Collection
  92.     {
  93.         return $this->newsGaleries;
  94.     }
  95.     public function addNewsGalery(NewsGalerie $newsGalery): static
  96.     {
  97.         if (!$this->newsGaleries->contains($newsGalery)) {
  98.             $this->newsGaleries->add($newsGalery);
  99.             $newsGalery->setNews($this);
  100.         }
  101.         return $this;
  102.     }
  103.     public function removeNewsGalery(NewsGalerie $newsGalery): static
  104.     {
  105.         if ($this->newsGaleries->removeElement($newsGalery)) {
  106.             // set the owning side to null (unless already changed)
  107.             if ($newsGalery->getNews() === $this) {
  108.                 $newsGalery->setNews(null);
  109.             }
  110.         }
  111.         return $this;
  112.     }
  113.     public function getCover(): ?string
  114.     {
  115.         return $this->cover;
  116.     }
  117.     public function setCover(?string $cover): static
  118.     {
  119.         $this->cover $cover;
  120.         return $this;
  121.     }
  122.     public function getAuthor(): ?User
  123.     {
  124.         return $this->author;
  125.     }
  126.     public function setAuthor(?User $author): static
  127.     {
  128.         $this->author $author;
  129.         return $this;
  130.     }
  131.     public function isDropdownOpen(): ?bool
  132.     {
  133.         return $this->dropdownOpen;
  134.     }
  135.     public function setDropdownOpen(?bool $dropdownOpen): static
  136.     {
  137.         $this->dropdownOpen $dropdownOpen;
  138.         return $this;
  139.     }
  140.     public function getEditor(): ?User
  141.     {
  142.         return $this->editor;
  143.     }
  144.     public function setEditor(?User $editor): static
  145.     {
  146.         $this->editor $editor;
  147.         return $this;
  148.     }
  149.     public function getSchool(): ?School
  150.     {
  151.         return $this->school;
  152.     }
  153.     public function setSchool(?School $school): static
  154.     {
  155.         $this->school $school;
  156.         return $this;
  157.     }
  158.     /**
  159.      * @return Collection<int, NewsBookmark>
  160.      */
  161.     public function getNewsBookmarks(): Collection
  162.     {
  163.         return $this->newsBookmarks;
  164.     }
  165.     public function addNewsBookmark(NewsBookmark $newsBookmark): static
  166.     {
  167.         if (!$this->newsBookmarks->contains($newsBookmark)) {
  168.             $this->newsBookmarks->add($newsBookmark);
  169.             $newsBookmark->setNews($this);
  170.         }
  171.         return $this;
  172.     }
  173.     public function removeNewsBookmark(NewsBookmark $newsBookmark): static
  174.     {
  175.         if ($this->newsBookmarks->removeElement($newsBookmark)) {
  176.             // set the owning side to null (unless already changed)
  177.             if ($newsBookmark->getNews() === $this) {
  178.                 $newsBookmark->setNews(null);
  179.             }
  180.         }
  181.         return $this;
  182.     }
  183.     public function getYear(): ?SchoolYear
  184.     {
  185.         return $this->year;
  186.     }
  187.     public function setYear(?SchoolYear $year): static
  188.     {
  189.         $this->year $year;
  190.         return $this;
  191.     }
  192. }