src/Entity/ExclusionsCategory.php line 53

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\Serializer\Filter\PropertyFilter;
  6. use ApiPlatform\Core\Serializer\Filter\GroupFilter;
  7. use App\Repository\ExclusionsCategoryRepository;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Gedmo\Mapping\Annotation as Gedmo;
  10. use Symfony\Component\Serializer\Annotation\Groups;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. /**
  13.  * @ORM\Entity(repositoryClass=ExclusionsCategoryRepository::class)
  14.  * @ApiResource(
  15.  *     normalizationContext={
  16.  *         "groups"={"exclusion_category:read"}
  17.  *     },
  18.  *     denormalizationContext={
  19.  *          "groups"={"exclusion_category:write"}
  20.  *     },
  21.  *     collectionOperations={
  22.  *          "get"={
  23.  *              "security"="is_granted('ROLE_ADMIN')"
  24.  *          }, 
  25.  *          "post"={
  26.  *              "security"="is_granted('ROLE_ADMIN')"
  27.  *          }
  28.  *      },
  29.  *      itemOperations={
  30.  *          "get"={
  31.  *              "security"="is_granted('ROLE_ADMIN')"
  32.  *          }, 
  33.  *          "delete"={
  34.  *              "security"="is_granted('ROLE_ADMIN')"
  35.  *          }
  36.  *      }
  37.  * )
  38.  * @ApiFilter(GroupFilter::class, 
  39.  *      arguments={
  40.  *          "overrideDefaultGroups": true
  41.  *      }
  42.  * )
  43.  * @ApiFilter(PropertyFilter::class, 
  44.  *      arguments={
  45.  *          "parameterName"="fields", 
  46.  *          "overrideDefaultProperties"=true
  47.  *     }
  48.  * )
  49.  */
  50. class ExclusionsCategory
  51. {
  52.     /**
  53.      * @ORM\Id
  54.      * @ORM\GeneratedValue
  55.      * @ORM\Column(type="integer")
  56.      * @Groups({"exclusion_category:read", "exclusion_category:read:id", "category:read"})
  57.      */
  58.     private $id;
  59.     /**
  60.      * @ORM\ManyToOne(targetEntity=TvCompany::class, inversedBy="exclusionsCategories")
  61.      * @ORM\JoinColumn(nullable=true)
  62.      */
  63.     private $tvCompany;
  64.     /**
  65.      * @ORM\ManyToOne(targetEntity=Company::class, inversedBy="exclusionsCategories")
  66.      * @ORM\JoinColumn(nullable=true)
  67.      * @Assert\NotNull
  68.      * @Groups({"exclusion_category:read", "exclusion_category:read:company", "category:read", "category:write"})
  69.      */
  70.     private $company;
  71.     /**
  72.      * @ORM\ManyToOne(targetEntity=Category::class, inversedBy="exclusionsCategories")
  73.      * @ORM\JoinColumn(nullable=false)
  74.      */
  75.     private $category;
  76.     /**
  77.      * @ORM\Column(type="datetime")
  78.      * @Gedmo\Timestampable(on="create")
  79.      */
  80.     private $createdAt;
  81.     public function getId(): ?int
  82.     {
  83.         return $this->id;
  84.     }
  85.     public function getTvCompany(): ?TvCompany
  86.     {
  87.         return $this->tvCompany;
  88.     }
  89.     public function setTvCompany(?TvCompany $tvCompany): self
  90.     {
  91.         $this->tvCompany $tvCompany;
  92.         return $this;
  93.     }
  94.     public function getCompany(): ?Company
  95.     {
  96.         return $this->company;
  97.     }
  98.     public function setCompany(?Company $company): self
  99.     {
  100.         $this->company $company;
  101.         return $this;
  102.     }
  103.     public function getCategory(): ?Category
  104.     {
  105.         return $this->category;
  106.     }
  107.     public function setCategory(?Category $category): self
  108.     {
  109.         $this->category $category;
  110.         return $this;
  111.     }
  112.     public function getCreatedAt(): ?\DateTimeInterface
  113.     {
  114.         return $this->createdAt;
  115.     }
  116.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  117.     {
  118.         $this->createdAt $createdAt;
  119.         return $this;
  120.     }
  121. }