src/Entity/Cart/GiftCart.php line 75

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Cart;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Controller\Api\Cart\Gift\CreateGiftCart;
  5. use App\Controller\Api\Cart\Gift\CreateOrRemoveGiftCart;
  6. use App\Controller\Api\Cart\Gift\RemoveGiftCart;
  7. use App\Controller\Api\Cart\Gift\GetUserGiftCarts;
  8. use App\Entity\Catalog\Gift;
  9. use App\Repository\Cart\GiftCartRepository;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Symfony\Component\Serializer\Annotation\Groups;
  12. use Symfony\Component\Serializer\Annotation\SerializedName;
  13. /**
  14.  * @ApiResource(
  15.  *     attributes={
  16.  *          "normalization_context"={"groups"={
  17.  *              "GiftCart:output",
  18.  *              "GiftCart:io",
  19.  *              "get_user_gift_carts",
  20.  *              "get_user_operation_carts",
  21.  *          }},
  22.  *          "denormalization_context"={"groups"={
  23.  *              "GiftCart:input",
  24.  *              "GiftCart:io",
  25.  *          }}
  26.  *      },
  27.  *     collectionOperations={
  28.  *          "post",
  29.  *          "get-user-gift-carts"={
  30.  *              "method"="GET",
  31.  *              "path"="/get-user-gift-carts",
  32.  *              "access_control"="is_granted('ROLE_USER')",
  33.  *              "validation_groups"={"get_user_gift_carts"},
  34.  *              "controller"=GetUserGiftCarts::class,
  35.  *              "defaults"={"_api_receive"=false},
  36.  *          },
  37.  *     },
  38.  *     itemOperations={
  39.  *          "get",
  40.  *          "delete" = {
  41.  *              "method"="DELETE",
  42.  *              "access_control"="is_granted('ROLE_USER')",
  43.  *          },
  44.  *          "post-create-gift-cart"={
  45.  *              "method"="POST",
  46.  *              "path"="/post-create-gift-cart/{giftId}",
  47.  *              "access_control"="is_granted('ROLE_USER')",
  48.  *              "validation_groups"={"post_ajax_gift_cart"},
  49.  *              "controller"=CreateGiftCart::class,
  50.  *              "defaults"={"_api_receive"=false},
  51.  *          },
  52.  *          "post-remove-gift-cart"={
  53.  *              "method"="POST",
  54.  *              "path"="/post-remove-gift-cart/{giftId}",
  55.  *              "access_control"="is_granted('ROLE_USER')",
  56.  *              "validation_groups"={"post_ajax_gift_cart"},
  57.  *              "controller"=RemoveGiftCart::class,
  58.  *              "defaults"={"_api_receive"=false},
  59.  *          },
  60.  *          "post-gift-cart"={
  61.  *              "method"="POST",
  62.  *              "path"="/post-gift-cart/{giftId}",
  63.  *              "access_control"="is_granted('ROLE_USER')",
  64.  *              "validation_groups"={"post_ajax_gift_cart"},
  65.  *              "controller"=CreateOrRemoveGiftCart::class,
  66.  *              "defaults"={"_api_receive"=false},
  67.  *          },
  68.  *     }
  69.  * )
  70.  * @ORM\Entity(repositoryClass=GiftCartRepository::class)
  71.  */
  72. class GiftCart extends Cart
  73. {
  74.     /**
  75.      * @ORM\ManyToOne(targetEntity=Gift::class, inversedBy="carts")
  76.      * @ORM\JoinColumn(name="object_id")
  77.      * @SerializedName("gift")
  78.      * @Groups({
  79.      *     "GiftCart:output",
  80.      *     "post_ajax_gift_cart",
  81.      *     "get_user_gift_carts",
  82.      * })
  83.      */
  84.     private ?Gift $gift;
  85.     /**
  86.      * @ORM\Column(type="integer")
  87.      * @SerializedName("value")
  88.      * @Groups({
  89.      *     "GiftCart:output",
  90.      *     "post_ajax_gift_cart",
  91.      *     "get_user_gift_carts",
  92.      * })
  93.      */
  94.     private $value;
  95.     public function getGift(): ?Gift
  96.     {
  97.         return $this->gift;
  98.     }
  99.     public function setGift(?Gift $gift): self
  100.     {
  101.         $this->gift $gift;
  102.         return $this;
  103.     }
  104.     public function getValue()
  105.     {
  106.         return $this->value;
  107.     }
  108.     public function setValue($value)
  109.     {
  110.         $this->value $value;
  111.         return $this;
  112.     }
  113. }