src/Entity/News.php line 33

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  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 ApiPlatform\Metadata\ApiFilter;
  10. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  11. use Symfony\Component\Serializer\Annotation\Groups;
  12. use ApiPlatform\Metadata\Delete;
  13. use ApiPlatform\Metadata\Get;
  14. use ApiPlatform\Metadata\GetCollection;
  15. use ApiPlatform\Metadata\Post;
  16. use ApiPlatform\Metadata\Put;
  17. #[ORM\Entity(repositoryClassNewsRepository::class)]
  18. #[ApiResource(
  19.     normalizationContext: ['groups' => ['news:read']],
  20.     denormalizationContext: ['groups' => ['news:write']],
  21.     order: ['id' => 'DESC'], paginationClientItemsPerPagetrue,
  22.     // security: "is_granted('ROLE_ADMIN')"
  23.     )
  24. ]
  25. #[Get()]
  26. #[Put(security"is_granted('EDIT_NEWS', object)")]
  27. #[Delete(security"is_granted('EDIT_NEWS', object)")]
  28. #[GetCollection]
  29. #[Post(securityPostDenormalize"is_granted('EDIT_NEWS', object)")]
  30. #[ApiFilter(SearchFilter::class, properties: [
  31.     'categories.id' => 'exact'
  32.     'name' => 'ipartial',
  33.     'language.id' => 'exact'
  34. ])]
  35. class News
  36. {
  37.     #[Groups(['news:read''news:write'])]
  38.     #[ORM\Id]
  39.     #[ORM\GeneratedValue]
  40.     #[ORM\Column]
  41.     private ?int $id null;
  42.     #[Groups(['news:read''news:write'])]
  43.     #[ORM\Column(length255)]
  44.     private ?string $name null;
  45.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  46.     #[Groups(['news:read''news:write'])]
  47.     private ?\DateTimeInterface $date null;
  48.     #[Groups(['news:read''news:write'])]
  49.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  50.     private ?string $newsShot null;
  51.     #[Groups(['news:read''news:write'])]
  52.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  53.     private ?string $newsFull null;
  54.     #[Groups(['news:read''news:write'])]
  55.     #[ORM\Column(length2nullabletrue)]
  56.     private ?string $active null;
  57.     #[Groups(['news:read''news:write'])]
  58.     #[ORM\Column(length2nullabletrue)]
  59.     private ?string $top null;
  60.     #[Groups(['news:read''news:write'])]
  61.     #[ORM\Column(length255nullabletrue)]
  62.     private ?string $audio_link null;
  63.     #[Groups(['news:read''news:write'])]
  64.     #[ORM\Column(length255nullabletrue)]
  65.     private ?string $video_link null;
  66.     #[Groups(['news:read''news:write'])]
  67.     #[ORM\Column(length255nullabletrue)]
  68.     private ?string $audio_title null;
  69.     #[Groups(['news:read''news:write'])]
  70.     #[ORM\Column(length2nullabletrue)]
  71.     private ?string $audio_active null;
  72.     #[Groups(['news:read''news:write'])]
  73.     #[ORM\Column(length255nullabletrue)]
  74.     private ?string $video_img null;
  75.     #[ORM\Column(length255nullabletrue)]
  76.     private ?string $slider null;
  77.     #[ORM\Column(length255nullabletrue)]
  78.     private ?string $dateStart null;
  79.     #[ORM\Column(length255nullabletrue)]
  80.     private ?string $address null;
  81.     #[ORM\Column(length255nullabletrue)]
  82.     private ?string $shortDescription null;
  83.     #[ORM\Column(length255nullabletrue)]
  84.     private ?string $contentImg null;
  85.     #[Groups(['news:read''news:write'])]
  86.     #[ORM\ManyToMany(targetEntityCategory::class, mappedBy'news')]
  87.     private Collection $categories;
  88.     #[Groups(['news:read''news:write'])]
  89.     #[ORM\ManyToOne(inversedBy'news')]
  90.     private ?MediaObject $media null;
  91.     #[Groups(['news:read''news:write'])]
  92.     #[ORM\ManyToOne(inversedBy'news')]
  93.     private ?Languages $language null;
  94.     #[Groups(['news:read''news:write'])]
  95.     #[ORM\ManyToOne(targetEntityself::class, inversedBy'tralations')]
  96.     private ?self $translation null;
  97.     /**
  98.      * @var Collection<int, self>
  99.      */
  100.     #[Groups(['news:read''news:write'])]
  101.     #[ORM\OneToMany(mappedBy'translation'targetEntityself::class)]
  102.     private Collection $tralations
  103.     
  104.     #[Groups(['news:read''news:write'])]
  105.     #[ORM\Column(length255nullabletrue)]
  106.     private ?string $opacityCard null
  107.     #[Groups(['news:read''news:write'])]
  108.     #[ORM\Column(length255nullabletrue)]
  109.     private ?string $seoTitle null;
  110.     #[Groups(['news:read''news:write'])]
  111.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  112.     private ?string $seoDescription null;
  113.     public function __construct() 
  114.     {
  115.         $this->categories = new ArrayCollection();
  116.         $this->tralations = new ArrayCollection();
  117.     }
  118.     public function getId(): ?int
  119.     {
  120.         return $this->id;
  121.     }
  122.     public function getName(): ?string
  123.     {
  124.         return $this->name;
  125.     }
  126.     public function setName(string $name): self
  127.     {
  128.         $this->name $name;
  129.         return $this;
  130.     }
  131.     public function getDate(): ?\DateTimeInterface
  132.     {
  133.         return $this->date;
  134.     }
  135.     public function setDate(\DateTimeInterface $date): self
  136.     {
  137.         $this->date $date;
  138.         return $this;
  139.     }
  140.     public function getNewsShot(): ?string
  141.     {
  142.         return $this->newsShot;
  143.     }
  144.     public function setNewsShot(?string $newsShot): self
  145.     {
  146.         $this->newsShot $newsShot;
  147.         return $this;
  148.     }
  149.     public function getNewsFull(): ?string
  150.     {
  151.         return $this->newsFull;
  152.     }
  153.     public function setNewsFull(?string $newsFull): self
  154.     {
  155.         $this->newsFull $newsFull;
  156.         return $this;
  157.     }
  158.     public function getActive(): ?string
  159.     {
  160.         return $this->active;
  161.     }
  162.     public function setActive(string $active): self
  163.     {
  164.         $this->active $active;
  165.         return $this;
  166.     }
  167.     public function getTop(): ?string
  168.     {
  169.         return $this->top;
  170.     }
  171.     public function setTop(?string $top): self
  172.     {
  173.         $this->top $top;
  174.         return $this;
  175.     }
  176.     public function getAudioLink(): ?string
  177.     {
  178.         return $this->audio_link;
  179.     }
  180.     public function setAudioLink(?string $audio_link): self
  181.     {
  182.         $this->audio_link $audio_link;
  183.         return $this;
  184.     }
  185.     public function getVideoLink(): ?string
  186.     {
  187.         return $this->video_link;
  188.     }
  189.     public function setVideoLink(?string $video_link): self
  190.     {
  191.         $this->video_link $video_link;
  192.         return $this;
  193.     }
  194.     public function getAudioTitle(): ?string
  195.     {
  196.         return $this->audio_title;
  197.     }
  198.     public function setAudioTitle(?string $audio_title): self
  199.     {
  200.         $this->audio_title $audio_title;
  201.         return $this;
  202.     }
  203.     public function getAudioActive(): ?string
  204.     {
  205.         return $this->audio_active;
  206.     }
  207.     public function setAudioActive(?string $audio_active): self
  208.     {
  209.         $this->audio_active $audio_active;
  210.         return $this;
  211.     }
  212.     public function getVideoImg(): ?string
  213.     {
  214.         return $this->video_img;
  215.     }
  216.     public function setVideoImg(?string $video_img): self
  217.     {
  218.         $this->video_img $video_img;
  219.         return $this;
  220.     }
  221.     public function getSlider(): ?string
  222.     {
  223.         return $this->slider;
  224.     }
  225.     public function setSlider(?string $slider): static
  226.     {
  227.         $this->slider $slider;
  228.         
  229.         return $this;
  230.     }
  231.     /**
  232.      * @return Collection<int, Category>
  233.      */
  234.     public function getCategories(): Collection
  235.     {
  236.         return $this->categories;
  237.     }
  238.     public function addCategory(Category $category): static
  239.     {
  240.         if (!$this->categories->contains($category)) {
  241.             $this->categories->add($category);
  242.             $category->addNews($this);
  243.         }
  244.         return $this;
  245.     }
  246.     public function getDateStart(): ?string
  247.     {
  248.         return $this->dateStart;
  249.     }
  250.     public function setDateStart(?string $dateStart): static
  251.     {
  252.         $this->dateStart $dateStart;
  253.         return $this;
  254.     }
  255.     public function getAddress(): ?string
  256.     {
  257.         return $this->address;
  258.     }
  259.     public function setAddress(?string $address): static
  260.     {
  261.         $this->address $address;
  262.         return $this;
  263.     }
  264.     public function getShortDescription(): ?string
  265.     {
  266.         return $this->shortDescription;
  267.     }
  268.     public function setShortDescription(?string $shortDescription): static
  269.     {
  270.         $this->shortDescription $shortDescription;
  271.         return $this;
  272.     }
  273.     public function getContentImg(): ?string
  274.     {
  275.         return $this->contentImg;
  276.     }
  277.     public function setContentImg(?string $contentImg): static
  278.     {
  279.         $this->contentImg $contentImg;
  280.         
  281.         return $this;
  282.     }
  283.     public function removeCategory(Category $category): static
  284.     {
  285.         if ($this->categories->removeElement($category)) {
  286.             $category->removeNews($this);
  287.         }
  288.         return $this;
  289.     }
  290.     public function getMedia(): ?MediaObject
  291.     {
  292.         return $this->media;
  293.     }
  294.     public function setMedia(?MediaObject $media): static
  295.     {
  296.         $this->media $media;
  297.         return $this;
  298.     }
  299.     public function getLanguage(): ?Languages
  300.     {
  301.         return $this->language;
  302.     }
  303.     public function setLanguage(?Languages $language): static
  304.     {
  305.         $this->language $language;
  306.         return $this;
  307.     }
  308.     public function getTranslation(): ?self
  309.     {
  310.         return $this->translation;
  311.     }
  312.     public function setTranslation(?self $translation): static
  313.     {
  314.         $this->translation $translation;
  315.         return $this;
  316.     }
  317.     /**
  318.      * @return Collection<int, self>
  319.      */
  320.     public function getTralations(): Collection
  321.     {
  322.         return $this->tralations;
  323.     }
  324.     public function addTralation(self $tralation): static
  325.     {
  326.         if (!$this->tralations->contains($tralation)) {
  327.             $this->tralations->add($tralation);
  328.             $tralation->setTranslation($this);
  329.         }
  330.         return $this;
  331.     }
  332.     public function removeTralation(self $tralation): static
  333.     {
  334.         if ($this->tralations->removeElement($tralation)) {
  335.             // set the owning side to null (unless already changed)
  336.             if ($tralation->getTranslation() === $this) {
  337.                 $tralation->setTranslation(null);
  338.             }
  339.         }
  340.         return $this;
  341.     }
  342.     
  343.     public function getOpacityCard(): ?string
  344.     {
  345.         return $this->opacityCard;
  346.     }
  347.     public function setOpacityCard(?string $opacityCard): static
  348.     {
  349.         $this->opacityCard $opacityCard;
  350.         return $this;
  351.     }
  352.     public function getSeoTitle(): ?string
  353.     {
  354.         return $this->seoTitle;
  355.     }
  356.     public function setSeoTitle(?string $seoTitle): static
  357.     {
  358.         $this->seoTitle $seoTitle;
  359.         return $this;
  360.     }
  361.     public function getSeoDescription(): ?string
  362.     {
  363.         return $this->seoDescription;
  364.     }
  365.     public function setSeoDescription(?string $seoDescription): static
  366.     {
  367.         $this->seoDescription $seoDescription;
  368.         return $this;
  369.     }
  370. }