src/Entity/Notation.php line 55

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiFilter;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use ApiPlatform\Core\Annotation\ApiSubresource;
  6. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
  7. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  8. use ApiPlatform\Core\Serializer\Filter\PropertyFilter;
  9. use App\Repository\NotationRepository;
  10. use Doctrine\Common\Collections\ArrayCollection;
  11. use Doctrine\Common\Collections\Collection;
  12. use Doctrine\ORM\Mapping as ORM;
  13. use Gedmo\Mapping\Annotation as Gedmo;
  14. use Symfony\Component\Serializer\Annotation\Groups;
  15. use Symfony\Component\Validator\Constraints as Assert;
  16. /**
  17.  * @ORM\Entity(repositoryClass=NotationRepository::class)
  18.  * @ApiResource(
  19.  *     normalizationContext={
  20.  *         "groups"={"notation:read"}
  21.  *     },
  22.  *     denormalizationContext={
  23.  *          "groups"={"notation:write"}
  24.  *     },
  25.  *     collectionOperations={
  26.  *          "get"={
  27.  *              "security"="is_granted('ROLE_USER')"
  28.  *          },
  29.  *          "post"={
  30.  *              "security"="is_granted('ROLE_USER')"
  31.  *          }
  32.  *     },
  33.  *     itemOperations={
  34.  *          "get"={
  35.  *              "security"="is_granted('ROLE_USER')"
  36.  *          }, 
  37.  *          "patch"={
  38.  *              "security"="is_granted('ROLE_USER')"
  39.  *          }, 
  40.  *          "delete"={
  41.  *              "security"="is_granted('ROLE_ADMIN')"
  42.  *          }
  43.  *      }
  44.  * )
  45.  * @ApiFilter(PropertyFilter::class, 
  46.  *      arguments={
  47.  *          "parameterName"="fields", 
  48.  *          "overrideDefaultProperties"=true
  49.  *     }
  50.  * )
  51.  */
  52. class Notation
  53. {
  54.     /**
  55.      * @ORM\Id
  56.      * @ORM\GeneratedValue
  57.      * @ORM\Column(type="integer")
  58.      * @Groups({"video:read", "notation:read"})
  59.      */
  60.     private $id;
  61.     /**
  62.      * @ORM\ManyToOne(targetEntity=Video::class, inversedBy="notations")
  63.      * @Groups({"video:read", "notation:read", "notation:write"})
  64.      */
  65.     private $video;
  66.     /**
  67.      * @ORM\ManyToOne(targetEntity=TvUser::class, inversedBy="notations")
  68.      * @ORM\JoinColumn(nullable=true)
  69.      */
  70.     private $tvUser;
  71.     /**
  72.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="notations")
  73.      * @ORM\JoinColumn(nullable=true)
  74.      * @Assert\NotNull
  75.      * @Groups({"video:read", "notation:read", "notation:write"})
  76.      */
  77.     private $user;
  78.     /**
  79.      * @ORM\Column(type="datetime")
  80.      * @Gedmo\Timestampable(on="create")
  81.      * @Groups({"notation:read"})
  82.      */
  83.     private $createdAt;
  84.     /**
  85.      * @ORM\Column(type="integer", nullable=true)
  86.      * @Groups({"video:read", "notation:read", "notation:write"})
  87.      */
  88.     private $notationQuality;
  89.     /**
  90.      * @ORM\Column(type="integer", nullable=true)
  91.      * @Groups({"video:read", "notation:read", "notation:write"})
  92.      */
  93.     private $notationExpert;
  94.     /**
  95.      * @ORM\Column(type="integer", nullable=true)
  96.      * @Groups({"video:read", "notation:read", "notation:write"})
  97.      */
  98.     private $notationPresentation;
  99.     /**
  100.      * @ORM\Column(type="datetime")
  101.      * @Gedmo\Timestampable(on="update")
  102.      * @Groups({"notation:read"})
  103.      */
  104.     private $updatedAt;
  105.     /**
  106.      * @ORM\Column(type="boolean", options={"default": "1"})
  107.      * @Groups({"notation:read", "notation:write"})
  108.      */
  109.     private $asRated true;
  110.     public function getId(): ?int
  111.     {
  112.         return $this->id;
  113.     }
  114.     public function getVideo(): ?Video
  115.     {
  116.         return $this->video;
  117.     }
  118.     public function setVideo(?Video $video): self
  119.     {
  120.         $this->video $video;
  121.         return $this;
  122.     }
  123.     public function getTvUser(): ?TvUser
  124.     {
  125.         return $this->tvUser;
  126.     }
  127.     public function setTvUser(?TvUser $tvUser): self
  128.     {
  129.         $this->tvUser $tvUser;
  130.         return $this;
  131.     }
  132.     public function getUser(): ?User
  133.     {
  134.         return $this->user;
  135.     }
  136.     public function setUser(?User $user): self
  137.     {
  138.         $this->user $user;
  139.         return $this;
  140.     }
  141.     public function getCreatedAt(): ?\DateTimeInterface
  142.     {
  143.         return $this->createdAt;
  144.     }
  145.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  146.     {
  147.         $this->createdAt $createdAt;
  148.         return $this;
  149.     }
  150.     public function getNotationQuality(): ?int
  151.     {
  152.         return $this->notationQuality;
  153.     }
  154.     public function setNotationQuality(?int $notationQuality): self
  155.     {
  156.         $this->notationQuality $notationQuality;
  157.         return $this;
  158.     }
  159.     public function getNotationExpert(): ?int
  160.     {
  161.         return $this->notationExpert;
  162.     }
  163.     public function setNotationExpert(?int $notationExpert): self
  164.     {
  165.         $this->notationExpert $notationExpert;
  166.         return $this;
  167.     }
  168.     public function getNotationPresentation(): ?int
  169.     {
  170.         return $this->notationPresentation;
  171.     }
  172.     public function setNotationPresentation(?int $notationPresentation): self
  173.     {
  174.         $this->notationPresentation $notationPresentation;
  175.         return $this;
  176.     }
  177.     public function getUpdatedAt(): ?\DateTimeInterface
  178.     {
  179.         return $this->updatedAt;
  180.     }
  181.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  182.     {
  183.         $this->updatedAt $updatedAt;
  184.         return $this;
  185.     }
  186.     public function getAsRated(): ?bool
  187.     {
  188.         return $this->asRated;
  189.     }
  190.     public function setAsRated(bool $asRated): self
  191.     {
  192.         $this->asRated $asRated;
  193.         return $this;
  194.     }
  195. }