src/V4/Entity/CustomAction.php line 101

Open in your IDE?
  1. <?php
  2. namespace App\V4\Entity;
  3. use ApiPlatform\Core\Annotation\ApiFilter;
  4. use ApiPlatform\Core\Annotation\ApiProperty;
  5. use ApiPlatform\Core\Annotation\ApiResource;
  6. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. /**
  10.  * @ApiResource(
  11.  *     shortName="V4/CustomAction",
  12.  *     attributes={
  13.  *         "api_allow_update": true
  14.  *     },
  15.  *     collectionOperations={
  16.  *         "get": {
  17.  *             "path": "/V4/custom_actions",
  18.  *             "normalization_context": {
  19.  *                 "groups": {"custom_action:list"}
  20.  *             }
  21.  *         },
  22.  *         "post_custom_action": {
  23.  *             "method": "POST",
  24.  *             "deserialize": false,
  25.  *             "write": false,
  26.  *             "controller": "App\V4\Controller\CustomAction\CustomActionDataPersisterAction",
  27.  *             "path": "/V4/custom_actions",
  28.  *             "input_formats": {
  29.  *                 "multipart": {"multipart/form-data"}
  30.  *             },
  31.  *             "normalization_context": {
  32.  *                  "groups": {"custom_action:write"}
  33.  *             },
  34.  *             "denormalization_context": {
  35.  *                  "groups": {}
  36.  *             }
  37.  *         },
  38.  *         "get_form": {
  39.  *             "method": "GET",
  40.  *             "path": "/V4/custom_actions/form",
  41.  *             "controller": App\V4\Controller\CustomAction\GetCustomActionFormAction::class
  42.  *         },
  43.  *     },
  44.  *     itemOperations={
  45.  *         "get": {
  46.  *             "path": "/V4/custom_actions/{id}",
  47.  *             "normalization_context": {
  48.  *                 "groups": {"custom_action:read"}
  49.  *             }
  50.  *         },
  51.  *         "get_form": {
  52.  *             "method": "GET",
  53.  *             "path": "/V4/custom_actions/{id}/form",
  54.  *             "controller": App\V4\Controller\CustomAction\GetCustomActionFormAction::class
  55.  *         },
  56.  *         "put_custom_action": {
  57.  *             "method": "POST",
  58.  *             "deserialize": false,
  59.  *             "write": false,
  60.  *             "controller": "App\V4\Controller\CustomAction\CustomActionDataPersisterAction",
  61.  *             "path": "/V4/custom_actions/{id}",
  62.  *             "input_formats": {
  63.  *                 "multipart": {"multipart/form-data"}
  64.  *             },
  65.  *             "normalization_context": {
  66.  *                  "groups": {"custom_action:update"}
  67.  *             },
  68.  *             "denormalization_context": {
  69.  *                  "groups": {}
  70.  *             }
  71.  *         },
  72.  *         "apply": {
  73.  *             "method": "POST",
  74.  *             "deserialize": false,
  75.  *             "write": false,
  76.  *             "controller": "App\V4\Controller\CustomAction\CustomActionAction",
  77.  *             "path": "/custom-actions/{id}/apply",
  78.  *             "input_formats": {
  79.  *                 "multipart": {"multipart/form-data"}
  80.  *             }
  81.  *         },
  82.  *         "delete": {
  83.  *             "path": "/V4/custom_actions/{id}",
  84.  *         }
  85.  *     }
  86.  * )
  87.  *
  88.  * @ApiFilter(SearchFilter::class, properties={
  89.  *    "id": "exact",
  90.  *    "customerId": "exact"
  91.  * })
  92.  *
  93.  * @ORM\Entity(repositoryClass="App\V4\Repository\CustomActionRepository")
  94.  * @ORM\Table(name="custom_action", indexes={
  95.  *     @ORM\Index(name="IX_CustomerAction_CustomerId", columns={"customer_id"})
  96.  * })
  97.  */
  98. class CustomAction
  99. {
  100.     /**
  101.      * @var string
  102.      *
  103.      * @ApiProperty(identifier=true)
  104.      *
  105.      * @ORM\Id()
  106.      * @ORM\GeneratedValue(strategy="CUSTOM")
  107.      * @ORM\CustomIdGenerator(class="App\Doctrine\UuidGenerator")
  108.      * @ORM\Column(name="id", type="string")
  109.      *
  110.      * @Groups({
  111.      *     "custom_action:list", "custom_action:read"
  112.      * })
  113.      */
  114.     private $id;
  115.     /**
  116.      * @var string
  117.      *
  118.      * @ORM\Column(type="string", length=100)
  119.      *
  120.      * @Groups({
  121.      *     "custom_action:list", "custom_action:read", "custom_action:write", "custom_action:update"
  122.      * })
  123.      */
  124.     private $name;
  125.     /**
  126.      * @var string
  127.      *
  128.      * @ORM\Column(type="string", length=255)
  129.      *
  130.      * @Groups({
  131.      *     "custom_action:list", "custom_action:read", "custom_action:write", "custom_action:update"
  132.      * })
  133.      */
  134.     private $entity;
  135.     /**
  136.      * @var string
  137.      *
  138.      * @ORM\Column(type="text")
  139.      *
  140.      * @Groups({
  141.      *     "custom_action:list", "custom_action:read", "custom_action:write", "custom_action:update"
  142.      * })
  143.      */
  144.     private $config;
  145.     /**
  146.      * @var int
  147.      *
  148.      * @ORM\Column(type="integer", options={"default": 0})
  149.      *
  150.      * @Groups({
  151.      *      "custom_action:list", "custom_action:read", "custom_action:write", "custom_action:update"
  152.      * })
  153.      */
  154.     private $position;
  155.     /**
  156.      * @var string
  157.      *
  158.      * @ORM\Column(type="string", length=255)
  159.      *
  160.      * @Groups({
  161.      *     "custom_action:list", "custom_action:read", "custom_action:write"
  162.      * })
  163.      */
  164.     private $customerId;
  165.     /**
  166.      * @return string|null
  167.      */
  168.     public function getId(): ?string
  169.     {
  170.         return $this->id;
  171.     }
  172.     /**
  173.      * @param string|null $id
  174.      *
  175.      * @return $this
  176.      */
  177.     public function setId(?string $id): self
  178.     {
  179.         $this->id $id;
  180.         return $this;
  181.     }
  182.     /**
  183.      * @return string|null
  184.      */
  185.     public function getName(): ?string
  186.     {
  187.         return $this->name;
  188.     }
  189.     /**
  190.      * @param string $name
  191.      *
  192.      * @return $this
  193.      */
  194.     public function setName(string $name): self
  195.     {
  196.         $this->name $name;
  197.         return $this;
  198.     }
  199.     /**
  200.      * @return string|null
  201.      */
  202.     public function getEntity(): ?string
  203.     {
  204.         return $this->entity;
  205.     }
  206.     /**
  207.      * @param string $entity
  208.      *
  209.      * @return $this
  210.      */
  211.     public function setEntity(string $entity): self
  212.     {
  213.         $this->entity $entity;
  214.         return $this;
  215.     }
  216.     /**
  217.      * @return string|null
  218.      */
  219.     public function getConfig(): ?string
  220.     {
  221.         return $this->config;
  222.     }
  223.     /**
  224.      * @param string $config
  225.      *
  226.      * @return $this
  227.      */
  228.     public function setConfig(string $config): self
  229.     {
  230.         $this->config $config;
  231.         return $this;
  232.     }
  233.     /**
  234.      * @return int
  235.      */
  236.     public function getPosition(): ?int
  237.     {
  238.         return $this->position;
  239.     }
  240.     /**
  241.      * @param int $position
  242.      *
  243.      * @return $this
  244.      */
  245.     public function setPosition(int $position): self
  246.     {
  247.         $this->position $position;
  248.         return $this;
  249.     }
  250.     /**
  251.      * @return string
  252.      */
  253.     public function getCustomerId(): ?string
  254.     {
  255.         return $this->customerId;
  256.     }
  257.     /**
  258.      * @param string $customerId
  259.      *
  260.      * @return $this
  261.      */
  262.     public function setCustomerId(string $customerId): self
  263.     {
  264.         $this->customerId $customerId;
  265.         return $this;
  266.     }
  267. }