src/Entity/Ean/Ean.php line 50

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Ean;
  3. use ApiPlatform\Core\Annotation\ApiProperty;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use App\Entity\Details\Operation\DetailsMultiOffer;
  6. use App\Entity\Details\Operation\DetailsOperation;
  7. use App\Repository\Ean\EanRepository;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\Common\Collections\Collection;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Gedmo\Timestampable\Traits\TimestampableEntity;
  12. use Ramsey\Uuid\Doctrine\UuidGenerator;
  13. use Symfony\Component\Serializer\Annotation\Groups;
  14. use Symfony\Component\Serializer\Annotation\SerializedName;
  15. use App\Entity\Ean\Participation\EanParticipation;
  16. /**
  17.  * @ApiResource(
  18.  *     attributes={
  19.  *          "normalization_context"={
  20.  *              "groups"={
  21.  *                  "Ean:output",
  22.  *                  "Ean:io"
  23.  *               },
  24.  *          },
  25.  *          "denormalization_context"={
  26.  *              "groups"={
  27.  *                  "Ean:output",
  28.  *                  "Ean:io"
  29.  *               },
  30.  *          }
  31.  *      },
  32.  *     collectionOperations={
  33.  *          "get"={
  34.  *              "method"="GET",
  35.  *              "access_control"="is_granted('ROLE_USER')",
  36.  *          },
  37.  *     },
  38.  *     itemOperations={
  39.  *          "get"={
  40.  *              "method"="GET",
  41.  *              "access_control"="is_granted('ROLE_USER')",
  42.  *          },
  43.  *      }
  44.  * )
  45.  * @ORM\Entity(repositoryClass=EanRepository::class)
  46.  */
  47. class Ean
  48. {
  49.     /**
  50.      * Hook timestampable behavior
  51.      * updates createdAt, updatedAt fields
  52.      */
  53.     use TimestampableEntity;
  54.     /**
  55.      * @ORM\Id
  56.      * @ORM\Column(type="uuid", unique=true)
  57.      * @ORM\GeneratedValue(strategy="CUSTOM")
  58.      * @ORM\CustomIdGenerator(class=UuidGenerator::class)
  59.      * @SerializedName("id")
  60.      * @ApiProperty(identifier=true)
  61.      * @Groups({
  62.      *     "Ean:output",
  63.      *     "OperationStep:output",
  64.      *     "OperationPuntos:output",
  65.      *     "OperationOdr:output",
  66.      *     "DetailsStep:output",
  67.      *     "DetailsPuntos:output",
  68.      *     "DetailsOdr:output",
  69.      *     "ParticipationOdr:io",
  70.      *     "DetailsMultiOffer:io",
  71.      *     "OperationMultiOffer:io",
  72.      *     "get_all_public_steps",
  73.      *     "get_all_public_odrs",
  74.      *     "get_steps_by_user_department",
  75.      *     "get_participation_odrs_by_user",
  76.      *     "get_participation_odrs_by_id",
  77.      * })
  78.      */
  79.     private string $id;
  80.     /**
  81.      * @var string
  82.      *
  83.      * @ORM\Column(name="code", type="string", nullable=false)
  84.      * @SerializedName("code")
  85.      * @Groups({
  86.      *     "Ean:output",
  87.      *     "OperationStep:output",
  88.      *     "OperationPuntos:output",
  89.      *     "OperationOdr:output",
  90.      *     "DetailsStep:output",
  91.      *     "DetailsPuntos:output",
  92.      *     "DetailsOdr:output",
  93.      *     "ParticipationStep:output",
  94.      *     "ParticipationOdr:output",
  95.      *     "ParticipationMulti:io",
  96.      *     "DetailsMultiOffer:io",
  97.      *     "OperationMultiOffer:io",
  98.      *     "get_all_public_steps",
  99.      *     "get_all_public_odrs",
  100.      *     "get_steps_by_user_department",
  101.      *     "get_participation_odrs_by_user",
  102.      *     "get_participation_odrs_by_id",
  103.      * })
  104.      */
  105.     private string $code;
  106.     /**
  107.      * @var string
  108.      *
  109.      * @ORM\Column(name="label", type="string", nullable=true)
  110.      * @SerializedName("label")
  111.      * @Groups({
  112.      *     "Ean:output",
  113.      *     "OperationOdr:output",
  114.      *     "ParticipationOdr:io",
  115.      *     "ParticipationMulti:io",
  116.      *     "DetailsOdr:output",
  117.      *     "get_all_public_odrs",
  118.      *     "get_steps_by_user_department",
  119.      *     "get_participation_odrs_by_user",
  120.      *     "get_participation_odrs_by_id",
  121.      *     "DetailsMultiOffer:io",
  122.      *     "OperationMultiOffer:io",
  123.      * })
  124.      */
  125.     private ?string $label null;
  126.     /**
  127.      * @var integer
  128.      *
  129.      * @ORM\Column(name="quantity", type="integer", nullable=true)
  130.      * @SerializedName("quantity")
  131.      * @Groups({
  132.      *     "Ean:output",
  133.      *     "OperationStep:output",
  134.      *     "OperationPuntos:output",
  135.      *     "OperationOdr:output",
  136.      *     "DetailsStep:output",
  137.      *     "DetailsPuntos:output",
  138.      *     "DetailsOdr:output",
  139.      *     "get_all_public_steps",
  140.      *     "get_all_public_odrs",
  141.      *     "ParticipationStep:io",
  142.      *     "get_steps_by_user_department",
  143.      * })
  144.      */
  145.     private $quantity;
  146.     /**
  147.      * @ORM\Column(name="amount", type="float", nullable=true)
  148.      * @SerializedName("amount")
  149.      * @Groups({
  150.      *     "Ean:output",
  151.      *     "OperationStep:output",
  152.      *     "OperationPuntos:output",
  153.      *     "OperationOdr:output",
  154.      *     "DetailsStep:output",
  155.      *     "DetailsPuntos:output",
  156.      *     "DetailsOdr:output",
  157.      *     "get_all_public_steps",
  158.      *     "get_all_public_odrs",
  159.      *     "ParticipationStep:io",
  160.      *     "ParticipationOdr:io",
  161.      *     "get_steps_by_user_department",
  162.      *     "get_participation_odrs_by_user",
  163.      *     "get_participation_odrs_by_id",
  164.      * })
  165.      */
  166.     private $amount;
  167.     /**
  168.      * @ORM\ManyToOne(targetEntity=DetailsOperation::class, inversedBy="eans")
  169.      * @ORM\JoinColumn(nullable=true)
  170.      */
  171.     private ?DetailsOperation $detailsOperation;
  172.     /**
  173.      * @ORM\OneToMany(targetEntity=EanParticipation::class, mappedBy="ean")
  174.      */
  175.     private $eanParticipations;
  176.     /**
  177.      * @ORM\ManyToOne(targetEntity=DetailsMultiOffer::class, inversedBy="eans")
  178.      * @Groups({
  179.      *     "DetailsMultiOffer:io",
  180.      *     "OperationMultiOffer:io",
  181.      * })
  182.      */
  183.     private $detailsMultiOffer;
  184.     public function __construct()
  185.     {
  186.         //$this->participationStep = new ArrayCollection();
  187.         $this->eanParticipations = new ArrayCollection();
  188.     }
  189.     /**
  190.      * @return string
  191.      */
  192.     public function getId() : string
  193.     {
  194.         return $this->id;
  195.     }
  196.     public function getDetailsOperation(): ?DetailsOperation
  197.     {
  198.         return $this->detailsOperation;
  199.     }
  200.     public function setDetailsOperation(?DetailsOperation $detailsOperation): self
  201.     {
  202.         $this->detailsOperation $detailsOperation;
  203.         return $this;
  204.     }
  205.     /**
  206.      * @return string
  207.      */
  208.     public function getCode() : string
  209.     {
  210.         return $this->code;
  211.     }
  212.     /**
  213.      * @param string $code
  214.      *
  215.      * @return Ean
  216.      */
  217.     public function setCode(string $code) : Ean
  218.     {
  219.         $this->code $code;
  220.         return $this;
  221.     }
  222.     /**
  223.      * @return string
  224.      */
  225.     public function getLabel() : ?string
  226.     {
  227.         return $this->label;
  228.     }
  229.     /**
  230.      * @param string $label
  231.      *
  232.      * @return Ean
  233.      */
  234.     public function setLabel(string $label) : Ean
  235.     {
  236.         $this->label $label;
  237.         return $this;
  238.     }
  239.     /**
  240.      * @return Collection|EanParticipation[]
  241.      */
  242.     public function getEanParticipations(): Collection
  243.     {
  244.         return $this->eanParticipations;
  245.     }
  246.     public function addEanStep(EanParticipation $eanParticipations): self
  247.     {
  248.         if (!$this->eanParticipations->contains($eanParticipations)) {
  249.             $this->eanParticipations[] = $eanParticipations;
  250.             $eanParticipations->setEan($this);
  251.         }
  252.         return $this;
  253.     }
  254.     public function removeEanStep(EanParticipation $eanParticipations): self
  255.     {
  256.         if ($this->eanParticipations->removeElement($eanParticipations)) {
  257.             // set the owning side to null (unless already changed)
  258.             if ($eanParticipations->getEan() === $this) {
  259.                 $eanParticipations->setEan(null);
  260.             }
  261.         }
  262.         return $this;
  263.     }
  264.     public function getQuantity() : ?int
  265.     {
  266.         return $this->quantity;
  267.     }
  268.     public function setQuantity(?int $quantity) : Ean
  269.     {
  270.         $this->quantity $quantity;
  271.         return $this;
  272.     }
  273.     public function getAmount()
  274.     {
  275.         return $this->amount;
  276.     }
  277.     public function setAmount($amount)
  278.     {
  279.         $this->amount $amount;
  280.         return $this;
  281.     }
  282.     public function getDetailsMultiOffer(): ?DetailsMultiOffer
  283.     {
  284.         return $this->detailsMultiOffer;
  285.     }
  286.     public function setDetailsMultiOffer(?DetailsMultiOffer $detailsMultiOffer): self
  287.     {
  288.         $this->detailsMultiOffer $detailsMultiOffer;
  289.         return $this;
  290.     }
  291. }