src/Entity/Ean/Participation/EanParticipation.php line 69

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Ean\Participation;
  3. use ApiPlatform\Core\Annotation\ApiProperty;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use App\Entity\Participation\Participation;
  6. use App\Repository\Ean\EanStepRepository;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Gedmo\Timestampable\Traits\TimestampableEntity;
  9. use Ramsey\Uuid\Doctrine\UuidGenerator;
  10. use Symfony\Component\Serializer\Annotation\Groups;
  11. use Symfony\Component\Serializer\Annotation\SerializedName;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. use Gedmo\Mapping\Annotation as Gedmo;
  14. use App\Entity\Ean\Ean;
  15. /**
  16.  * @ORM\Entity(repositoryClass=EanStepRepository::class)
  17.  * @ApiResource(
  18.  *     attributes={
  19.  *          "normalization_context"={
  20.  *              "groups"={
  21.  *                  "EanParticipation:output",
  22.  *                  "EanParticipation:io",
  23.  *               }
  24.  *          },
  25.  *          "denormalization_context"={
  26.  *              "groups"={
  27.  *                  "EanParticipation:input",
  28.  *                  "EanParticipation:io",
  29.  *              }
  30.  *          }
  31.  *      },
  32.  *     collectionOperations={
  33.  *          "post"={
  34.  *              "method"="POST",
  35.  *              "access_control"="is_granted('ROLE_USER')",
  36.  *          },
  37.  *          "admin-post"={
  38.  *              "method"="POST",
  39.  *              "path"="/admin/ean_participation",
  40.  *              "access_control"="is_granted('ROLE_ADMIN_API')",
  41.  *              "validation_groups"={"Default", "Create"}
  42.  *          },
  43.  *          "get"={
  44.  *              "method"="GET",
  45.  *              "access_control"="is_granted('ROLE_USER')",
  46.  *          },
  47.  *     },
  48.  *     itemOperations={
  49.  *          "get"={
  50.  *              "method"="GET",
  51.  *              "access_control"="is_granted('ROLE_USER')",
  52.  *          },
  53.  *     },
  54.  * )
  55.  * @ORM\Entity()
  56.  * @ORM\InheritanceType("SINGLE_TABLE")
  57.  * @ORM\DiscriminatorColumn(name="discr", type="string")
  58.  * @ORM\DiscriminatorMap({
  59.  *     "ean_participation" = "EanParticipation",
  60.  *     "ean_step" = "EanStep",
  61.  *     "ean_puntos" = "EanPuntos",
  62.  *     "ean_odr" = "EanOdr",
  63.  * })
  64.  * @Gedmo\Loggable
  65.  */
  66. class EanParticipation
  67. {
  68.     /**
  69.      * Hook timestampable behavior
  70.      * updates createdAt, updatedAt fields
  71.      */
  72.     use TimestampableEntity;
  73.     /**
  74.      * @ORM\Id
  75.      * @ORM\Column(type="uuid", unique=true)
  76.      * @ORM\GeneratedValue(strategy="CUSTOM")
  77.      * @ORM\CustomIdGenerator(class=UuidGenerator::class)
  78.      * @SerializedName("id")
  79.      * @ApiProperty(identifier=true)
  80.      * @Groups({
  81.      *     "ParticipationStep:io",
  82.      *     "ParticipationOdr:io",
  83.      *     "ParticipationPuntos:io",
  84.      *     "EanParticipation:io",
  85.      *     "EanPuntos:io",
  86.      *     "EanStep:io",
  87.      *     "EanOdr:io",
  88.      *     "get_steps_by_user_department",
  89.      *     "get_odrs_by_user_department",
  90.      * })
  91.      */
  92.     private string $id;
  93.     /**
  94.      * @ORM\Column(type="integer")
  95.      * @Groups({
  96.      *     "ParticipationStep:io",
  97.      *     "ParticipationOdr:io",
  98.      *     "ParticipationPuntos:io",
  99.      *     "EanParticipation:io",
  100.      *     "EanStep:io",
  101.      *     "EanPuntos:io",
  102.      *     "EanOdr:io",
  103.      *     "get_steps_by_user_department",
  104.      *     "get_odrs_by_user_department",
  105.      *     "get_participation-steps_by_user",
  106.      *     "get_participation_odrs_by_user",
  107.      *     "get_participation_odrs_by_id",
  108.      * })
  109.      * @Assert\NotBlank()
  110.      * @Assert\GreaterThanOrEqual(value="1")
  111.      * @Gedmo\Versioned
  112.      */
  113.     private $quantity;
  114.     /**
  115.      * @ORM\ManyToOne(targetEntity=Ean::class, inversedBy="eanParticipations")
  116.      * @ORM\JoinColumn(nullable=true)
  117.      *
  118.      * @Groups({
  119.      *     "ParticipationStep:io",
  120.      *     "ParticipationOdr:io",
  121.      *     "ParticipationPuntos:io",
  122.      *     "ParticipationMulti:io",
  123.      *     "EanParticipation:io",
  124.      *     "EanStep:io",
  125.      *     "EanOdr:io",
  126.      *     "EanPuntos:io",
  127.      *     "get_steps_by_user_department",
  128.      *     "get_odrs_by_user_department",
  129.      *     "get_participation-steps_by_user",
  130.      *     "get_participation_odrs_by_user",
  131.      *     "get_participation_odrs_by_id",
  132.      * })
  133.      * @Assert\NotBlank()
  134.      * @Assert\Valid()
  135.      * @Gedmo\Versioned
  136.      */
  137.     private $ean;
  138.     /**
  139.      * @ORM\ManyToOne(targetEntity=Participation::class, inversedBy="eanParticipations")
  140.      * @Groups({
  141.      *     "ParticipationStep:io",
  142.      *     "ParticipationOdr:io",
  143.      *     "ParticipationPuntos:io",
  144.      *     "EanParticipation:io",
  145.      *     "EanStep:io",
  146.      *     "EanOdr:io",
  147.      *     "EanPuntos:io",
  148.      *     "get_participation-steps_by_user",
  149.      *     "get_participation_odrs_by_user",
  150.      *     "get_participation_odrs_by_id",
  151.      * })
  152.      * @Assert\NotBlank()
  153.      * @Assert\Valid()
  154.      */
  155.     private $participation;
  156.     /**
  157.      * The amount returned by numeo if null amount sent
  158.      * @var null|float
  159.      * @ORM\Column(type="float", nullable=true)
  160.      * @Assert\Type(type="float")
  161.      */
  162.     private $validatedAmount;
  163.     /**
  164.      * @ORM\Column(type="string", length=1, nullable=true)
  165.      * @Assert\Length(min="1", max="1")
  166.      */
  167.     private $barcodeStatus;
  168.     public function getId(): ?string
  169.     {
  170.         return $this->id;
  171.     }
  172.     public function getQuantity(): ?int
  173.     {
  174.         return $this->quantity;
  175.     }
  176.     public function setQuantity(int $quantity): self
  177.     {
  178.         $this->quantity $quantity;
  179.         return $this;
  180.     }
  181.     public function getEan(): ?Ean
  182.     {
  183.         return $this->ean;
  184.     }
  185.     public function setEan(?Ean $ean): self
  186.     {
  187.         $this->ean $ean;
  188.         return $this;
  189.     }
  190.     /**
  191.      * @return mixed
  192.      */
  193.     public function getParticipation()
  194.     {
  195.         return $this->participation;
  196.     }
  197.     /**
  198.      * @param mixed $participation
  199.      * @return EanParticipation
  200.      */
  201.     public function setParticipation($participation): EanParticipation
  202.     {
  203.         $this->participation $participation;
  204.         return $this;
  205.     }
  206.     /**
  207.      * @return float
  208.      */
  209.     public function getValidatedAmount(): float
  210.     {
  211.         return $this->validatedAmount ?? 0;
  212.     }
  213.     /**
  214.      * @param float|null $validatedAmount
  215.      * @return EanParticipation
  216.      */
  217.     public function setValidatedAmount(float $validatedAmount): EanParticipation
  218.     {
  219.         $this->validatedAmount $validatedAmount;
  220.         return $this;
  221.     }
  222.     public function getBarcodeStatus(): ?string
  223.     {
  224.         return $this->barcodeStatus;
  225.     }
  226.     public function setBarcodeStatus(?string $barcodeStatus): EanParticipation
  227.     {
  228.         $this->barcodeStatus $barcodeStatus;
  229.         return $this;
  230.     }
  231. }