src/Entity/Operation/Draw.php line 59

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Operation;
  3. use ApiPlatform\Core\Annotation\ApiFilter;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\BooleanFilter;
  6. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\DateFilter;
  7. use App\Entity\MediaObject\MediaCodeDraw;
  8. use App\Entity\MediaObject\MediaDesktopDraw;
  9. use App\Entity\MediaObject\MediaMobileDraw;
  10. use App\Entity\MediaObject\MediaPdfDraw;
  11. use App\Entity\MediaObject\MediaThumbnailDraw;
  12. use App\Entity\Tas\TasDraw;
  13. use App\Repository\Operation\DrawRepository;
  14. use Doctrine\Common\Annotations\Annotation\IgnoreAnnotation;
  15. use Doctrine\Common\Collections\ArrayCollection;
  16. use Doctrine\Common\Collections\Collection;
  17. use Doctrine\ORM\Mapping as ORM;
  18. use Symfony\Component\Serializer\Annotation\Groups;
  19. use Symfony\Component\Serializer\Annotation\SerializedName;
  20. use Symfony\Component\Validator\Constraints as Assert;
  21. /**
  22.  * @ApiResource(
  23.  *     attributes={
  24.  *          "force_eager"=false,
  25.  *          "normalization_context"={"groups"={
  26.  *              "OperationDraw:output",
  27.  *              "OperationDraw:io",
  28.  *              "get_all_public_draw",
  29.  *          }},
  30.  *          "denormalization_context"={"groups"={
  31.  *              "OperationDraw:input",
  32.  *              "OperationDraw:io",
  33.  *          }}
  34.  *      },
  35.  *     collectionOperations={
  36.  *          "get-public"={
  37.  *              "path"="/public/draws",
  38.  *              "method"="GET",
  39.  *              "access_control"="is_granted('ROLE_PUBLIC')",
  40.  *          },
  41.  *          "get"={
  42.  *              "method"="GET",
  43.  *              "access_control"="is_granted('ROLE_USER')",
  44.  *          }
  45.  *     },
  46.  *     itemOperations={
  47.  *          "get-public"={
  48.  *              "method"="GET",
  49.  *              "path"="/public/draw/{id}",
  50.  *          }
  51.  *     }
  52.  * )
  53.  *
  54.  * @ORM\Entity(repositoryClass=DrawRepository::class)
  55.  */
  56. class Draw extends Operation
  57. {
  58.     public const DRAW_TYPE_DEMAT 'demat';
  59.     public const DRAW_TYPE_PHYSIC 'physic';
  60.     public const ARRAY_DRAW_TYPE = [
  61.         self::DRAW_TYPE_PHYSIC,
  62.         self::DRAW_TYPE_DEMAT,
  63.     ];
  64.     /**
  65.      * @var string|null
  66.      * @ORM\Column(name="draw_type", type="string")
  67.      * @SerializedName("draw_type")
  68.      * @Groups({
  69.      *     "OperationDraw:output",
  70.      * })
  71.      */
  72.     private ?string $drawType;
  73.     /**
  74.      * @ORM\Column(type="datetime", options={"default": "CURRENT_TIMESTAMP"})
  75.      * @SerializedName("start_date")
  76.      * @Groups({
  77.      *     "OperationDraw:output"
  78.      * })
  79.      * @ApiFilter(DateFilter::class, strategy=DateFilter::EXCLUDE_NULL)
  80.      */
  81.     private $startDate;
  82.     /**
  83.      * @ORM\Column(type="datetime", options={"default": "CURRENT_TIMESTAMP"})
  84.      * @SerializedName("end_date")
  85.      * @Groups({
  86.      *     "OperationDraw:output"
  87.      * })
  88.      * @ApiFilter(DateFilter::class, strategy=DateFilter::EXCLUDE_NULL)
  89.      */
  90.     private $endDate;
  91.     /**
  92.      * @ORM\Column(type="datetime", options={"default": "CURRENT_TIMESTAMP"})
  93.      * @SerializedName("draw_date")
  94.      * @Groups({
  95.      *     "OperationDraw:output"
  96.      * })
  97.      * @ApiFilter(DateFilter::class, strategy=DateFilter::EXCLUDE_NULL)
  98.      */
  99.     private $drawDate;
  100.     /**
  101.      * @ORM\Column(type="boolean", options={"default": 0})
  102.      * @SerializedName("online")
  103.      * @Groups({
  104.      *     "OperationDraw:output"
  105.      * })
  106.      * @ApiFilter(BooleanFilter::class)
  107.      */
  108.     private bool $online false;
  109.     /**
  110.      * @ORM\Column(type="string", length=255, nullable=true)
  111.      * @SerializedName("subtitle")
  112.      * @Groups({
  113.      *     "OperationDraw:output",
  114.      * })
  115.      */
  116.     private ?string $subtitle;
  117.     /**
  118.      * @ORM\Column(type="text", nullable=true)
  119.      * @SerializedName("text")
  120.      * @Groups({
  121.      *     "OperationDraw:output",
  122.      * })
  123.      */
  124.     private ?string $text;
  125.     /**
  126.      * @var MediaThumbnailDraw|null
  127.      * @ORM\OneToMany(targetEntity=MediaThumbnailDraw::class, mappedBy="draw", cascade={"persist"})
  128.      * @SerializedName("thumbnail_draws")
  129.      * @Groups({
  130.      *     "OperationDraw:output",
  131.      *     "MediaThumbnailDraw:io",
  132.      * })
  133.      */
  134.     private $thumbnailDraws;
  135.     /**
  136.      * @var MediaDesktopDraw|null
  137.      * @ORM\OneToMany(targetEntity=MediaDesktopDraw::class, mappedBy="draw", cascade={"persist"})
  138.      * @SerializedName("desktop_draws")
  139.      * @Groups({
  140.      *     "OperationDraw:output",
  141.      *     "MediaDesktopDraw:io",
  142.      * })
  143.      */
  144.     private $desktopDraws;
  145.     /**
  146.      * @var MediaMobileDraw|null
  147.      * @ORM\OneToMany(targetEntity=MediaMobileDraw::class, mappedBy="draw", cascade={"persist"})
  148.      * @SerializedName("mobile_draws")
  149.      * @Groups({
  150.      *     "OperationDraw:output",
  151.      *     "MediaMobileDraw:io",
  152.      * })
  153.      */
  154.     private $mobileDraws;
  155.     /**
  156.      * @var MediaPdfDraw|null
  157.      * @ORM\OneToMany(targetEntity=MediaPdfDraw::class, mappedBy="draw", cascade={"persist"})
  158.      * @SerializedName("pdf_draws")
  159.      * @Groups({
  160.      *     "OperationDraw:output",
  161.      *     "MediaPdfDraw:io",
  162.      * })
  163.      */
  164.     private $pdfDraws;
  165.     /**
  166.      * @var MediaCodeDraw|null
  167.      * @ORM\OneToMany(targetEntity=MediaCodeDraw::class, mappedBy="draw", cascade={"persist"})
  168.      * @SerializedName("media_code_draws")
  169.      * @Groups({
  170.      *     "MediaCodeDraw:io"
  171.      * })
  172.      */
  173.     private $mediaCodeDraws;
  174.     /**
  175.      * @ORM\Column(type="integer")
  176.      * @Groups({
  177.      *     "OperationDraw:output",
  178.      * })
  179.      * @Assert\NotBlank()
  180.      * @Assert\GreaterThanOrEqual(value="1")
  181.      */
  182.     private int $nbWinner;
  183.     /**
  184.      * @ORM\OneToMany(targetEntity=TasDraw::class, mappedBy="operation")
  185.      */
  186.     private Collection $tas;
  187.     /**
  188.      * @ORM\Column(type="text", nullable=true)
  189.      * @SerializedName("transport_reference")
  190.      * @Groups({
  191.      *     "OperationDraw:output"
  192.      * })
  193.      */
  194.     private $transportReference;
  195.     /**
  196.      * @ORM\Column(type="text", nullable=true, length=8)
  197.      * @Assert\Length(
  198.      *     min="8",
  199.      *     max="8",
  200.      * )
  201.      * @SerializedName("bext_reference")
  202.      * @Groups({
  203.      *     "OperationDraw:output"
  204.      * })
  205.      */
  206.     private $bextReference;
  207.     /**
  208.      * @ORM\Column(type="boolean", options={"default": 0})
  209.      * @SerializedName("sogec_send")
  210.      * @Groups({
  211.      *     "OperationDraw:output"
  212.      * })
  213.      * @ApiFilter(BooleanFilter::class)
  214.      */
  215.     private bool $sogecSend false;
  216.     /**
  217.      * @ORM\Column(type="text", nullable=true)
  218.      * @SerializedName("mail_content")
  219.      * @Groups({
  220.      *     "OperationDraw:output"
  221.      * })
  222.      */
  223.     private ?string $mailContent;
  224.     public function __construct()
  225.     {
  226.         parent::__construct();
  227.         $this->thumbnailDraws = new ArrayCollection();
  228.         $this->desktopDraws = new ArrayCollection();
  229.         $this->mobileDraws = new ArrayCollection();
  230.         $this->pdfDraws = new ArrayCollection();
  231.         $this->tas = new ArrayCollection();
  232.     }
  233.     public function getDrawType(): ?string
  234.     {
  235.         return $this->drawType;
  236.     }
  237.     public function setDrawType(?string $drawType): self
  238.     {
  239.         $this->drawType $drawType;
  240.         return $this;
  241.     }
  242.     public function getStartDate(): ?\DateTimeInterface
  243.     {
  244.         return $this->startDate;
  245.     }
  246.     public function setStartDate(\DateTimeInterface $startDate): self
  247.     {
  248.         $this->startDate $startDate;
  249.         return $this;
  250.     }
  251.     public function getEndDate(): ?\DateTimeInterface
  252.     {
  253.         return $this->endDate;
  254.     }
  255.     public function setEndDate(\DateTimeInterface $endDate): self
  256.     {
  257.         $this->endDate $endDate;
  258.         return $this;
  259.     }
  260.     public function getDrawDate(): ?\DateTimeInterface
  261.     {
  262.         return $this->drawDate;
  263.     }
  264.     public function setDrawDate(\DateTimeInterface $drawDate): self
  265.     {
  266.         $this->drawDate $drawDate;
  267.         return $this;
  268.     }
  269.     public function isOnline(): bool
  270.     {
  271.         return (bool) $this->online;
  272.     }
  273.     public function getOnline(): bool
  274.     {
  275.         return (bool) $this->online;
  276.     }
  277.     public function setOnline(bool $online): self
  278.     {
  279.         $this->online $online;
  280.         return $this;
  281.     }
  282.     public function getSubtitle(): ?string
  283.     {
  284.         return $this->subtitle;
  285.     }
  286.     public function setSubtitle(?string $subtitle): Draw
  287.     {
  288.         $this->subtitle $subtitle;
  289.         return $this;
  290.     }
  291.     public function getText(): ?string
  292.     {
  293.         return $this->text;
  294.     }
  295.     public function setText(?string $text): Draw
  296.     {
  297.         $this->text $text;
  298.         return $this;
  299.     }
  300.     public function getThumbnailDraws()
  301.     {
  302.         return $this->thumbnailDraws;
  303.     }
  304.     public function setThumbnailDraw(MediaThumbnailDraw $thumbnailDraws): Draw
  305.     {
  306.         $this->thumbnailDraws $thumbnailDraws;
  307.         return $this;
  308.     }
  309.     public function addThumbnailDraw(MediaThumbnailDraw $thumbnailDraw)
  310.     {
  311.         if ($this->thumbnailDraws->contains($thumbnailDraw)) {
  312.             return;
  313.         }
  314.         $this->thumbnailDraws[] = $thumbnailDraw;
  315.         $thumbnailDraw->setDraw($this);
  316.     }
  317.     public function getDesktopDraws()
  318.     {
  319.         return $this->desktopDraws;
  320.     }
  321.     public function setDesktopDraw(MediaDesktopDraw $desktopDraws): Draw
  322.     {
  323.         $this->desktopDraws $desktopDraws;
  324.         return $this;
  325.     }
  326.     public function addDesktopDraw(MediaDesktopDraw $desktopDraw)
  327.     {
  328.         if ($this->desktopDraws->contains($desktopDraw)) {
  329.             return;
  330.         }
  331.         $this->desktopDraws[] = $desktopDraw;
  332.         $desktopDraw->setDraw($this);
  333.     }
  334.     public function getMobileDraws()
  335.     {
  336.         return $this->mobileDraws;
  337.     }
  338.     public function setMobileDraw(MediaMobileDraw $mobileDraws): Draw
  339.     {
  340.         $this->mobileDraws $mobileDraws;
  341.         return $this;
  342.     }
  343.     public function addMobileDraw(MediaMobileDraw $mobileDraw)
  344.     {
  345.         if ($this->mobileDraws->contains($mobileDraw)) {
  346.             return;
  347.         }
  348.         $this->mobileDraws[] = $mobileDraw;
  349.         $mobileDraw->setDraw($this);
  350.     }
  351.     public function getPdfDraws()
  352.     {
  353.         return $this->pdfDraws;
  354.     }
  355.     public function setPdfDraw(MediaPdfDraw $pdfDraws): Draw
  356.     {
  357.         $this->pdfDraws $pdfDraws;
  358.         return $this;
  359.     }
  360.     public function addPdfDraw(MediaPdfDraw $pdfDraw)
  361.     {
  362.         if ($this->pdfDraws->contains($pdfDraw)) {
  363.             return;
  364.         }
  365.         $this->pdfDraws[] = $pdfDraw;
  366.         $pdfDraw->setDraw($this);
  367.     }
  368.     public function getNbWinner(): int
  369.     {
  370.         return $this->nbWinner;
  371.     }
  372.     public function setNbWinner(int $nbWinner): Draw
  373.     {
  374.         $this->nbWinner $nbWinner;
  375.         return $this;
  376.     }
  377.     /**
  378.      * @return Collection|TasDraw[]
  379.      */
  380.     public function getTas(): Collection
  381.     {
  382.         return $this->tas;
  383.     }
  384.     public function addTas(TasDraw $tas): self
  385.     {
  386.         if (!$this->tas->contains($tas)) {
  387.             $this->tas[] = $tas;
  388.             $tas->setOperation($this);
  389.         }
  390.         return $this;
  391.     }
  392.     public function removeTas(TasDraw $tas): self
  393.     {
  394.         if ($this->tas->removeElement($tas)) {
  395.             // set the owning side to null (unless already changed)
  396.             if ($tas->getOperation() === $this) {
  397.                 $tas->setOperation(null);
  398.             }
  399.         }
  400.         return $this;
  401.     }
  402.     /**
  403.      * @return ?string
  404.      */
  405.     public function getTransportReference(): ?string
  406.     {
  407.         return $this->transportReference;
  408.     }
  409.     /**
  410.      * @param ?string $transportReference
  411.      * @return Draw
  412.      */
  413.     public function setTransportReference(?string $transportReference): self
  414.     {
  415.         $this->transportReference $transportReference;
  416.         return $this;
  417.     }
  418.     /**
  419.      * @return ?string
  420.      */
  421.     public function getBextReference()
  422.     {
  423.         return $this->bextReference;
  424.     }
  425.     /**
  426.      * @param ?string $bextReference
  427.      * @return Draw
  428.      */
  429.     public function setBextReference(?string $bextReference): self
  430.     {
  431.         $this->bextReference $bextReference;
  432.         return $this;
  433.     }
  434.     public function getSogecSend(): bool
  435.     {
  436.         return (bool) $this->sogecSend;
  437.     }
  438.     public function setSogecSend(bool $sogecSend): self
  439.     {
  440.         $this->sogecSend $sogecSend;
  441.         return $this;
  442.     }
  443.     public function getMailContent(): ?string
  444.     {
  445.         return $this->mailContent;
  446.     }
  447.     public function setMailContent(?string $mailContent): self
  448.     {
  449.         $this->mailContent $mailContent;
  450.         return $this;
  451.     }
  452. }