<?php
namespace App\Entity\Operation;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\BooleanFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\DateFilter;
use App\Entity\MediaObject\MediaCodeDraw;
use App\Entity\MediaObject\MediaDesktopDraw;
use App\Entity\MediaObject\MediaMobileDraw;
use App\Entity\MediaObject\MediaPdfDraw;
use App\Entity\MediaObject\MediaThumbnailDraw;
use App\Entity\Tas\TasDraw;
use App\Repository\Operation\DrawRepository;
use Doctrine\Common\Annotations\Annotation\IgnoreAnnotation;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\SerializedName;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ApiResource(
* attributes={
* "force_eager"=false,
* "normalization_context"={"groups"={
* "OperationDraw:output",
* "OperationDraw:io",
* "get_all_public_draw",
* }},
* "denormalization_context"={"groups"={
* "OperationDraw:input",
* "OperationDraw:io",
* }}
* },
* collectionOperations={
* "get-public"={
* "path"="/public/draws",
* "method"="GET",
* "access_control"="is_granted('ROLE_PUBLIC')",
* },
* "get"={
* "method"="GET",
* "access_control"="is_granted('ROLE_USER')",
* }
* },
* itemOperations={
* "get-public"={
* "method"="GET",
* "path"="/public/draw/{id}",
* }
* }
* )
*
* @ORM\Entity(repositoryClass=DrawRepository::class)
*/
class Draw extends Operation
{
public const DRAW_TYPE_DEMAT = 'demat';
public const DRAW_TYPE_PHYSIC = 'physic';
public const ARRAY_DRAW_TYPE = [
self::DRAW_TYPE_PHYSIC,
self::DRAW_TYPE_DEMAT,
];
/**
* @var string|null
* @ORM\Column(name="draw_type", type="string")
* @SerializedName("draw_type")
* @Groups({
* "OperationDraw:output",
* })
*/
private ?string $drawType;
/**
* @ORM\Column(type="datetime", options={"default": "CURRENT_TIMESTAMP"})
* @SerializedName("start_date")
* @Groups({
* "OperationDraw:output"
* })
* @ApiFilter(DateFilter::class, strategy=DateFilter::EXCLUDE_NULL)
*/
private $startDate;
/**
* @ORM\Column(type="datetime", options={"default": "CURRENT_TIMESTAMP"})
* @SerializedName("end_date")
* @Groups({
* "OperationDraw:output"
* })
* @ApiFilter(DateFilter::class, strategy=DateFilter::EXCLUDE_NULL)
*/
private $endDate;
/**
* @ORM\Column(type="datetime", options={"default": "CURRENT_TIMESTAMP"})
* @SerializedName("draw_date")
* @Groups({
* "OperationDraw:output"
* })
* @ApiFilter(DateFilter::class, strategy=DateFilter::EXCLUDE_NULL)
*/
private $drawDate;
/**
* @ORM\Column(type="boolean", options={"default": 0})
* @SerializedName("online")
* @Groups({
* "OperationDraw:output"
* })
* @ApiFilter(BooleanFilter::class)
*/
private bool $online = false;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @SerializedName("subtitle")
* @Groups({
* "OperationDraw:output",
* })
*/
private ?string $subtitle;
/**
* @ORM\Column(type="text", nullable=true)
* @SerializedName("text")
* @Groups({
* "OperationDraw:output",
* })
*/
private ?string $text;
/**
* @var MediaThumbnailDraw|null
* @ORM\OneToMany(targetEntity=MediaThumbnailDraw::class, mappedBy="draw", cascade={"persist"})
* @SerializedName("thumbnail_draws")
* @Groups({
* "OperationDraw:output",
* "MediaThumbnailDraw:io",
* })
*/
private $thumbnailDraws;
/**
* @var MediaDesktopDraw|null
* @ORM\OneToMany(targetEntity=MediaDesktopDraw::class, mappedBy="draw", cascade={"persist"})
* @SerializedName("desktop_draws")
* @Groups({
* "OperationDraw:output",
* "MediaDesktopDraw:io",
* })
*/
private $desktopDraws;
/**
* @var MediaMobileDraw|null
* @ORM\OneToMany(targetEntity=MediaMobileDraw::class, mappedBy="draw", cascade={"persist"})
* @SerializedName("mobile_draws")
* @Groups({
* "OperationDraw:output",
* "MediaMobileDraw:io",
* })
*/
private $mobileDraws;
/**
* @var MediaPdfDraw|null
* @ORM\OneToMany(targetEntity=MediaPdfDraw::class, mappedBy="draw", cascade={"persist"})
* @SerializedName("pdf_draws")
* @Groups({
* "OperationDraw:output",
* "MediaPdfDraw:io",
* })
*/
private $pdfDraws;
/**
* @var MediaCodeDraw|null
* @ORM\OneToMany(targetEntity=MediaCodeDraw::class, mappedBy="draw", cascade={"persist"})
* @SerializedName("media_code_draws")
* @Groups({
* "MediaCodeDraw:io"
* })
*/
private $mediaCodeDraws;
/**
* @ORM\Column(type="integer")
* @Groups({
* "OperationDraw:output",
* })
* @Assert\NotBlank()
* @Assert\GreaterThanOrEqual(value="1")
*/
private int $nbWinner;
/**
* @ORM\OneToMany(targetEntity=TasDraw::class, mappedBy="operation")
*/
private Collection $tas;
/**
* @ORM\Column(type="text", nullable=true)
* @SerializedName("transport_reference")
* @Groups({
* "OperationDraw:output"
* })
*/
private $transportReference;
/**
* @ORM\Column(type="text", nullable=true, length=8)
* @Assert\Length(
* min="8",
* max="8",
* )
* @SerializedName("bext_reference")
* @Groups({
* "OperationDraw:output"
* })
*/
private $bextReference;
/**
* @ORM\Column(type="boolean", options={"default": 0})
* @SerializedName("sogec_send")
* @Groups({
* "OperationDraw:output"
* })
* @ApiFilter(BooleanFilter::class)
*/
private bool $sogecSend = false;
/**
* @ORM\Column(type="text", nullable=true)
* @SerializedName("mail_content")
* @Groups({
* "OperationDraw:output"
* })
*/
private ?string $mailContent;
public function __construct()
{
parent::__construct();
$this->thumbnailDraws = new ArrayCollection();
$this->desktopDraws = new ArrayCollection();
$this->mobileDraws = new ArrayCollection();
$this->pdfDraws = new ArrayCollection();
$this->tas = new ArrayCollection();
}
public function getDrawType(): ?string
{
return $this->drawType;
}
public function setDrawType(?string $drawType): self
{
$this->drawType = $drawType;
return $this;
}
public function getStartDate(): ?\DateTimeInterface
{
return $this->startDate;
}
public function setStartDate(\DateTimeInterface $startDate): self
{
$this->startDate = $startDate;
return $this;
}
public function getEndDate(): ?\DateTimeInterface
{
return $this->endDate;
}
public function setEndDate(\DateTimeInterface $endDate): self
{
$this->endDate = $endDate;
return $this;
}
public function getDrawDate(): ?\DateTimeInterface
{
return $this->drawDate;
}
public function setDrawDate(\DateTimeInterface $drawDate): self
{
$this->drawDate = $drawDate;
return $this;
}
public function isOnline(): bool
{
return (bool) $this->online;
}
public function getOnline(): bool
{
return (bool) $this->online;
}
public function setOnline(bool $online): self
{
$this->online = $online;
return $this;
}
public function getSubtitle(): ?string
{
return $this->subtitle;
}
public function setSubtitle(?string $subtitle): Draw
{
$this->subtitle = $subtitle;
return $this;
}
public function getText(): ?string
{
return $this->text;
}
public function setText(?string $text): Draw
{
$this->text = $text;
return $this;
}
public function getThumbnailDraws()
{
return $this->thumbnailDraws;
}
public function setThumbnailDraw(MediaThumbnailDraw $thumbnailDraws): Draw
{
$this->thumbnailDraws = $thumbnailDraws;
return $this;
}
public function addThumbnailDraw(MediaThumbnailDraw $thumbnailDraw)
{
if ($this->thumbnailDraws->contains($thumbnailDraw)) {
return;
}
$this->thumbnailDraws[] = $thumbnailDraw;
$thumbnailDraw->setDraw($this);
}
public function getDesktopDraws()
{
return $this->desktopDraws;
}
public function setDesktopDraw(MediaDesktopDraw $desktopDraws): Draw
{
$this->desktopDraws = $desktopDraws;
return $this;
}
public function addDesktopDraw(MediaDesktopDraw $desktopDraw)
{
if ($this->desktopDraws->contains($desktopDraw)) {
return;
}
$this->desktopDraws[] = $desktopDraw;
$desktopDraw->setDraw($this);
}
public function getMobileDraws()
{
return $this->mobileDraws;
}
public function setMobileDraw(MediaMobileDraw $mobileDraws): Draw
{
$this->mobileDraws = $mobileDraws;
return $this;
}
public function addMobileDraw(MediaMobileDraw $mobileDraw)
{
if ($this->mobileDraws->contains($mobileDraw)) {
return;
}
$this->mobileDraws[] = $mobileDraw;
$mobileDraw->setDraw($this);
}
public function getPdfDraws()
{
return $this->pdfDraws;
}
public function setPdfDraw(MediaPdfDraw $pdfDraws): Draw
{
$this->pdfDraws = $pdfDraws;
return $this;
}
public function addPdfDraw(MediaPdfDraw $pdfDraw)
{
if ($this->pdfDraws->contains($pdfDraw)) {
return;
}
$this->pdfDraws[] = $pdfDraw;
$pdfDraw->setDraw($this);
}
public function getNbWinner(): int
{
return $this->nbWinner;
}
public function setNbWinner(int $nbWinner): Draw
{
$this->nbWinner = $nbWinner;
return $this;
}
/**
* @return Collection|TasDraw[]
*/
public function getTas(): Collection
{
return $this->tas;
}
public function addTas(TasDraw $tas): self
{
if (!$this->tas->contains($tas)) {
$this->tas[] = $tas;
$tas->setOperation($this);
}
return $this;
}
public function removeTas(TasDraw $tas): self
{
if ($this->tas->removeElement($tas)) {
// set the owning side to null (unless already changed)
if ($tas->getOperation() === $this) {
$tas->setOperation(null);
}
}
return $this;
}
/**
* @return ?string
*/
public function getTransportReference(): ?string
{
return $this->transportReference;
}
/**
* @param ?string $transportReference
* @return Draw
*/
public function setTransportReference(?string $transportReference): self
{
$this->transportReference = $transportReference;
return $this;
}
/**
* @return ?string
*/
public function getBextReference()
{
return $this->bextReference;
}
/**
* @param ?string $bextReference
* @return Draw
*/
public function setBextReference(?string $bextReference): self
{
$this->bextReference = $bextReference;
return $this;
}
public function getSogecSend(): bool
{
return (bool) $this->sogecSend;
}
public function setSogecSend(bool $sogecSend): self
{
$this->sogecSend = $sogecSend;
return $this;
}
public function getMailContent(): ?string
{
return $this->mailContent;
}
public function setMailContent(?string $mailContent): self
{
$this->mailContent = $mailContent;
return $this;
}
}