src/Entity/OperationCode/OperationCode.php line 50

Open in your IDE?
  1. <?php
  2. namespace App\Entity\OperationCode;
  3. use App\Repository\OperationCode\OperationCodeRepository;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use Symfony\Component\Serializer\Annotation\Groups;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Timestampable\Traits\TimestampableEntity;
  8. /**
  9.  * @ApiResource(
  10.  *      attributes={
  11.  *           "normalization_context"={
  12.  *               "groups"={
  13.  *                   "OperationCode:output",
  14.  *                   "OperationCode:io",
  15.  *                   "get_code_odr_by_participation_id",
  16.  *                },
  17.  *           },
  18.  *           "denormalization_context"={
  19.  *               "groups"={
  20.  *                   "OperationCode:output",
  21.  *                   "OperationCode:io",
  22.  *                   "get_code_odr_by_participation_id",
  23.  *                },
  24.  *           }
  25.  *       },
  26.  *      collectionOperations={
  27.  *           "get"={
  28.  *               "method"="GET",
  29.  *               "access_control"="is_granted('ROLE_USER')",
  30.  *           },
  31.  *      },
  32.  *      itemOperations={
  33.  *           "get"={
  34.  *               "method"="GET",
  35.  *               "access_control"="is_granted('ROLE_USER')",
  36.  *           },
  37.  *       }
  38.  *  )
  39.  * @ORM\Entity(repositoryClass=OperationCodeRepository::class)
  40.  * @ORM\InheritanceType("SINGLE_TABLE")
  41.  * @ORM\DiscriminatorColumn(name="discr", type="string")
  42.  * @ORM\DiscriminatorMap({
  43.  *     "draw" = "DrawCode",
  44.  *     "odr" = "OdrCode",
  45.  * })
  46.  */
  47. abstract class OperationCode
  48. {
  49.     /**
  50.      * Hook timestampable behavior
  51.      * updates createdAt, updatedAt fields
  52.      */
  53.     use TimestampableEntity;
  54.     public const PARAMS_USED_YES 'yes';
  55.     public const PARAMS_USED_NO 'no';
  56.     public const MAIL_CONTENT_VARIABLE_CODE '%CODE%';
  57.     /**
  58.      * @ORM\Id
  59.      * @ORM\GeneratedValue
  60.      * @ORM\Column(type="integer")
  61.      */
  62.     private ?int $id;
  63.     /**
  64.      * @ORM\Column(type="string", length=255)
  65.      * @Groups({
  66.      *      "get_code_odr_by_participation_id",
  67.      *  })
  68.      */
  69.     private string $code;
  70.     /**
  71.      * @ORM\Column(type="string", length=255, nullable=true)
  72.      * @Groups({
  73.      *      "get_code_odr_by_participation_id",
  74.      * })
  75.      */
  76.     private ?string $hiddenCode null;
  77.     public function getId(): ?int
  78.     {
  79.         return $this->id;
  80.     }
  81.     public function getCode(): string
  82.     {
  83.         return $this->code;
  84.     }
  85.     public function setCode(string $code): self
  86.     {
  87.         $this->code $code;
  88.         return $this;
  89.     }
  90.     public function getHiddenCode(): ?string
  91.     {
  92.         return $this->hiddenCode;
  93.     }
  94.     public function setHiddenCode(?string $hiddenCode): self
  95.     {
  96.         $this->hiddenCode $hiddenCode;
  97.         return $this;
  98.     }
  99. }