src/Entity/News.php line 59
<?phpnamespace App\Entity;use ApiPlatform\Doctrine\Orm\Filter\DateFilter;use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;use ApiPlatform\Metadata\ApiFilter;use ApiPlatform\Metadata\ApiResource;use ApiPlatform\Metadata\Get;use ApiPlatform\Metadata\GetCollection;use ApiPlatform\Serializer\Filter\PropertyFilter;use App\Repository\NewsRepository;use DateTimeImmutable;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;use Doctrine\ORM\Mapping\OrderBy;use Symfony\Component\Serializer\Annotation\Groups;#[ORM\Entity(repositoryClass: NewsRepository::class)]#[ApiFilter(PropertyFilter::class)]#[ApiResource(shortName: 'News',description: 'News API',operations: [new Get(uriTemplate: '/news/{id}'),//new Patch(uriTemplate: '/media/{id}'),new GetCollection(uriTemplate: '/news', paginationEnabled: false),],formats: ['jsonld','json','jsonhal','csv' => 'text/csv',],normalizationContext: ['groups' => ['news:read'],],denormalizationContext: ['groups' => ['news:write'],],paginationItemsPerPage: 9,),ApiFilter(OrderFilter::class,properties: ['newsDate',],),ApiFilter(DateFilter::class,properties: ['newsDate',])]class News{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]#[Groups(['news:read','studio:read','seo:read'])]#[ApiFilter(SearchFilter::class, strategy: 'exact')]private ?int $id = null;#[ORM\Column(length: 255)]#[Groups(['news:read','studio:read','news-category:read','seo:read'])]#[ApiFilter(SearchFilter::class, strategy: 'partial')]private ?string $title = null;#[ORM\Column(length: 255, nullable: true)]#[Groups(['news:read', 'studio:read','news-category:read'])]#[ApiFilter(SearchFilter::class, strategy: 'partial')]private ?string $quelle = null;#[ORM\Column(length: 255, nullable: true)]#[Groups(['news:read', 'studio:read','news-category:read'])]#[ApiFilter(SearchFilter::class, strategy: 'exact')]private ?string $type = null;#[ORM\Column(type: Types::TEXT)]#[Groups(['news:read','studio:read','news-category:read'])]#[ApiFilter(SearchFilter::class, strategy: 'partial')]private ?string $content = null;#[ORM\Column]#[Groups(['news:read','studio:read','news-category:read','seo:read'])]#[ApiFilter(SearchFilter::class, strategy: 'exact')]private ?bool $active = null;#[ORM\Column(nullable: true)]#[Groups(['news:read','studio:read','news-category:read','seo:read'])]#[ApiFilter(SearchFilter::class, strategy: 'partial')]private ?DateTimeImmutable $newsDate = null;#[ORM\ManyToOne(targetEntity: NewsCategory::class, inversedBy: 'news')]#[Groups(['news:read','studio:read'])]#[ApiFilter(SearchFilter::class, strategy: 'exact')]private ?NewsCategory $category;#[ORM\ManyToOne(inversedBy: 'news')]#[ORM\JoinColumn(nullable: true)]#[ApiFilter(SearchFilter::class, strategy: 'exact')]#[Groups(['news:read'])]protected ?Studio $studio;#[ORM\OneToMany(mappedBy: 'news', targetEntity: StudioMedia::class, cascade: ["persist"], orphanRemoval: true)]#[Groups(['news:read','studio:read','seo:read'])]protected Collection $studioMedia;#[ORM\Column]#[Groups(['news:read'])]private ?DateTimeImmutable $createdAt = null;#[ORM\Column(nullable: true)]#[Groups(['news:read'])]private ?int $coverId = null;public function __construct(){$this->createdAt = new DateTimeImmutable();$this->newsDate = new DateTimeImmutable();$this->active = true;$this->type = 'studio';$this->studioMedia = new ArrayCollection();}public function getId(): ?int{return $this->id;}public function getTitle(): ?string{return $this->title;}public function setTitle(string $title): self{$this->title = $title;return $this;}public function getQuelle(): ?string{return $this->quelle;}public function setQuelle(?string $quelle): self{$this->quelle = $quelle;return $this;}public function getContent(): ?string{return $this->content;}public function setContent(string $content): self{$this->content = $content;return $this;}public function getType(): ?string{return $this->type;}public function setType(?string $type): self{$this->type = $type;return $this;}public function isActive(): ?bool{return $this->active;}public function setActive(bool $active): self{$this->active = $active;return $this;}public function getNewsDate(): ?DateTimeImmutable{return $this->newsDate;}public function setNewsDate(?DateTimeImmutable $newsDate): self{$this->newsDate = $newsDate;return $this;}public function getCreatedAt(): ?DateTimeImmutable{return $this->createdAt;}public function setCreatedAt(DateTimeImmutable $createdAt): self{$this->createdAt = $createdAt;return $this;}public function getCategory(): ?NewsCategory{return $this->category;}public function setCategory(?NewsCategory $category): self{$this->category = $category;return $this;}public function getStudio(): ?Studio{return $this->studio;}public function setStudio(?Studio $studio): self{$this->studio = $studio;return $this;}/*** @return Collection<int, StudioMedia>*/public function getStudioMedia(): Collection{return $this->studioMedia;}public function addStudioMedium(StudioMedia $studioMedium): self{if (!$this->studioMedia->contains($studioMedium)) {$this->studioMedia->add($studioMedium);$studioMedium->setNews($this);}return $this;}public function removeStudioMedium(StudioMedia $studioMedium): self{if ($this->studioMedia->removeElement($studioMedium)) {// set the owning side to null (unless already changed)if ($studioMedium->getNews() === $this) {$studioMedium->setNews(null);}}return $this;}public function getCoverId(): ?int{return $this->coverId;}public function setCoverId(?int $coverId): self{$this->coverId = $coverId;return $this;}}