<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Annotation\ApiSubresource;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Core\Serializer\Filter\PropertyFilter;
use App\Repository\NotationRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=NotationRepository::class)
* @ApiResource(
* normalizationContext={
* "groups"={"notation:read"}
* },
* denormalizationContext={
* "groups"={"notation:write"}
* },
* collectionOperations={
* "get"={
* "security"="is_granted('ROLE_USER')"
* },
* "post"={
* "security"="is_granted('ROLE_USER')"
* }
* },
* itemOperations={
* "get"={
* "security"="is_granted('ROLE_USER')"
* },
* "patch"={
* "security"="is_granted('ROLE_USER')"
* },
* "delete"={
* "security"="is_granted('ROLE_ADMIN')"
* }
* }
* )
* @ApiFilter(PropertyFilter::class,
* arguments={
* "parameterName"="fields",
* "overrideDefaultProperties"=true
* }
* )
*/
class Notation
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({"video:read", "notation:read"})
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=Video::class, inversedBy="notations")
* @Groups({"video:read", "notation:read", "notation:write"})
*/
private $video;
/**
* @ORM\ManyToOne(targetEntity=TvUser::class, inversedBy="notations")
* @ORM\JoinColumn(nullable=true)
*/
private $tvUser;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="notations")
* @ORM\JoinColumn(nullable=true)
* @Assert\NotNull
* @Groups({"video:read", "notation:read", "notation:write"})
*/
private $user;
/**
* @ORM\Column(type="datetime")
* @Gedmo\Timestampable(on="create")
* @Groups({"notation:read"})
*/
private $createdAt;
/**
* @ORM\Column(type="integer", nullable=true)
* @Groups({"video:read", "notation:read", "notation:write"})
*/
private $notationQuality;
/**
* @ORM\Column(type="integer", nullable=true)
* @Groups({"video:read", "notation:read", "notation:write"})
*/
private $notationExpert;
/**
* @ORM\Column(type="integer", nullable=true)
* @Groups({"video:read", "notation:read", "notation:write"})
*/
private $notationPresentation;
/**
* @ORM\Column(type="datetime")
* @Gedmo\Timestampable(on="update")
* @Groups({"notation:read"})
*/
private $updatedAt;
/**
* @ORM\Column(type="boolean", options={"default": "1"})
* @Groups({"notation:read", "notation:write"})
*/
private $asRated = true;
public function getId(): ?int
{
return $this->id;
}
public function getVideo(): ?Video
{
return $this->video;
}
public function setVideo(?Video $video): self
{
$this->video = $video;
return $this;
}
public function getTvUser(): ?TvUser
{
return $this->tvUser;
}
public function setTvUser(?TvUser $tvUser): self
{
$this->tvUser = $tvUser;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getNotationQuality(): ?int
{
return $this->notationQuality;
}
public function setNotationQuality(?int $notationQuality): self
{
$this->notationQuality = $notationQuality;
return $this;
}
public function getNotationExpert(): ?int
{
return $this->notationExpert;
}
public function setNotationExpert(?int $notationExpert): self
{
$this->notationExpert = $notationExpert;
return $this;
}
public function getNotationPresentation(): ?int
{
return $this->notationPresentation;
}
public function setNotationPresentation(?int $notationPresentation): self
{
$this->notationPresentation = $notationPresentation;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getAsRated(): ?bool
{
return $this->asRated;
}
public function setAsRated(bool $asRated): self
{
$this->asRated = $asRated;
return $this;
}
}