src/Entity/Cart/OperationCart.php line 56

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Cart;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Controller\Api\Cart\Operation\CreateOrRemoveOperationCart;
  5. use App\Controller\Api\Cart\Operation\GetUserOperationCarts;
  6. use App\Entity\Operation\Operation;
  7. use App\Repository\Cart\OperationCartRepository;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. use Symfony\Component\Serializer\Annotation\SerializedName;
  11. /**
  12.  * @ApiResource(
  13.  *     attributes={
  14.  *          "normalization_context"={"groups"={
  15.  *              "OperationCart:output",
  16.  *              "OperationCart:io",
  17.  *              "get_user_operation_carts",
  18.  *          }},
  19.  *          "denormalization_context"={"groups"={
  20.  *              "OperationCart:input",
  21.  *              "OperationCart:io",
  22.  *          }}
  23.  *      },
  24.  *     collectionOperations={
  25.  *          "post",
  26.  *          "get-user-operation-carts"={
  27.  *              "method"="GET",
  28.  *              "path"="/get-user-operation-carts",
  29.  *              "access_control"="is_granted('ROLE_USER')",
  30.  *              "validation_groups"={"get_user_operation_carts"},
  31.  *              "controller"=GetUserOperationCarts::class,
  32.  *              "defaults"={"_api_receive"=false},
  33.  *          },
  34.  *     },
  35.  *     itemOperations={
  36.  *          "get",
  37.  *          "delete" = {
  38.  *              "method"="DELETE",
  39.  *              "access_control"="is_granted('ROLE_USER')",
  40.  *          },
  41.  *          "post-operation-cart"={
  42.  *              "method"="POST",
  43.  *              "path"="/post-operation-cart/{operationId}",
  44.  *              "access_control"="is_granted('ROLE_USER')",
  45.  *              "validation_groups"={"post_ajax_operation_cart"},
  46.  *              "controller"=CreateOrRemoveOperationCart::class,
  47.  *              "defaults"={"_api_receive"=false},
  48.  *          },
  49.  *     }
  50.  * )
  51.  * @ORM\Entity(repositoryClass=OperationCartRepository::class)
  52.  */
  53. class OperationCart extends Cart
  54. {
  55.     /**
  56.      * @ORM\ManyToOne(targetEntity=Operation::class, inversedBy="carts")
  57.      * @ORM\JoinColumn(name="object_id")
  58.      * @SerializedName("operation")
  59.      * @Groups({
  60.      *     "OperationCart:output",
  61.      *     "post_ajax_operation_cart",
  62.      *     "get_user_operation_carts",
  63.      * })
  64.      */
  65.     private ?Operation $operation;
  66.     /**
  67.      * @ORM\Column(type="string")
  68.      * @Groups({
  69.      *     "OperationCart:output",
  70.      *     "post_ajax_operation_cart",
  71.      *     "get_user_operation_carts",
  72.      * })
  73.      */
  74.     private $type;
  75.     public function getOperation(): ?Operation
  76.     {
  77.         return $this->operation;
  78.     }
  79.     public function setOperation(?Operation $operation): self
  80.     {
  81.         $this->operation $operation;
  82.         return $this;
  83.     }
  84.     public function getType()
  85.     {
  86.         return $this->type;
  87.     }
  88.     public function setType($type)
  89.     {
  90.         $this->type $type;
  91.         return $this;
  92.     }
  93. }