src/Entity/Participation/Participation.php line 30
<?php
namespace App\Entity\Participation;
use App\Entity\Code;
use App\Entity\Product;
use App\Entity\Stock;
use App\Entity\Traits\TimestampableTrait;
use App\Entity\User;
use App\Repository\Participation\ParticipationRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\SerializedName;
use Ramsey\Uuid\Doctrine\UuidGenerator;
use Ramsey\Uuid\UuidInterface as Uuid;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: ParticipationRepository::class)]
#[ORM\InheritanceType('SINGLE_TABLE')]
#[ORM\DiscriminatorColumn(name: 'discr', type: 'string')]
#[ORM\DiscriminatorMap([
'odr' => 'Odr',
'ig' => 'Ig',
'asso' => 'Asso',
'draw' => 'Draw'
])]
class Participation
{
use TimestampableTrait;
public const API_SOGEC_ACTION = 'create';
public const API_SOGEC_CHANNEL = 'FW';
public const PARTICIPATION_DISCR_ODR = 'odr';
public const PARTICIPATION_DISCR_IG = 'ig';
public const PARTICIPATION_DISCR_ASSO = 'asso';
public const PARTICIPATION_DISCR_DRAW = 'draw';
public const ARRAY_PARTICIPATION_DISCR = [
self::PARTICIPATION_DISCR_ODR,
self::PARTICIPATION_DISCR_IG,
self::PARTICIPATION_DISCR_ASSO,
self::PARTICIPATION_DISCR_DRAW
];
#[ORM\Id]
#[ORM\Column(type: "uuid", unique: true)]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
#[Assert\Uuid]
#[SerializedName('participation_id')]
#[Groups(['global'])]
private ?Uuid $uuid = null;
#[ORM\Column(length: 13, unique: true, nullable: true)]
private ?string $number = null;
#[ORM\Column(type: Types::BOOLEAN, nullable: true)]
private ?bool $isConform = null;
#[ORM\Column(type: Types::JSON, nullable: true)]
private array $reasonNotConformity = [];
#[ORM\Column(length: 10, nullable: true)]
private ?string $nonConformityType = null;
#[ORM\ManyToOne(cascade: ["persist"], inversedBy: 'participations')]
private ?User $user = null;
#[ORM\Column(type: Types::BOOLEAN, nullable: true)]
private ?bool $confirmed = null;
#[ORM\Column(nullable: true)]
private ?int $errorNumber = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $errorMessage = null;
#[ORM\Column(length: 50, nullable: true)]
private ?string $emailedNumber = null;
#[ORM\OneToOne(targetEntity: Code::class)]
#[ORM\JoinColumn(referencedColumnName: 'id')]
private ?Code $code = null;
//instant gagnant's id from api-instant-gagnant
#[ORM\Column(length: 100, nullable: true)]
private ?string $externalIdIG = null;
#[ORM\Column(nullable: true)]
private ?bool $draw = null;
#[ORM\ManyToOne(inversedBy: 'participations')]
private ?Product $ean = null;
#[ORM\ManyToMany(targetEntity: Stock::class, inversedBy: 'participations')]
#[ORM\JoinColumn(name: "participation_uuid", referencedColumnName: "uuid")]
private Collection $stocks;
public function __construct()
{
$this->stocks = new ArrayCollection();
}
#[SerializedName('date_participation')]
#[Groups(['global'])]
public function getParticipationDate(): string
{
return $this->createdAt->format("Y-m-d H:i:s");
}
#[SerializedName('code_promo')]
#[Groups(['global'])]
public function getCodePromo(): ?string
{
return $this->code?->getCode();
}
public function insertConstantValues(object $obj): object
{
$obj->action = self::API_SOGEC_ACTION;
$obj->channel = (in_array($this->code->getPalier(), ['PAL03', 'PAL04'])) ? 'FI' : self::API_SOGEC_CHANNEL;
return $obj;
}
public function getUuid(): ?Uuid
{
return $this->uuid;
}
public function getNumber(): ?string
{
return $this->number;
}
public function setNumber(?string $number): self
{
$this->number = $number;
return $this;
}
public function isIsConform(): ?bool
{
return $this->isConform;
}
public function setIsConform(?bool $isConform): self
{
$this->isConform = $isConform;
return $this;
}
public function getReasonNotConformity(): array
{
return $this->reasonNotConformity;
}
public function setReasonNotConformity(?array $reasonNotConformity): self
{
$this->reasonNotConformity = $reasonNotConformity;
return $this;
}
public function getNonConformityType(): ?string
{
return $this->nonConformityType;
}
public function setNonConformityType(?string $nonConformityType): self
{
$this->nonConformityType = $nonConformityType;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function isConfirmed(): ?bool
{
return $this->confirmed;
}
public function setConfirmed(?bool $confirmed): self
{
$this->confirmed = $confirmed;
return $this;
}
public function getErrorNumber(): ?int
{
return $this->errorNumber;
}
public function setErrorNumber(?int $errorNumber): self
{
$this->errorNumber = $errorNumber;
return $this;
}
public function getErrorMessage(): ?string
{
return $this->errorMessage;
}
public function setErrorMessage(?string $errorMessage): self
{
$this->errorMessage = $errorMessage;
return $this;
}
public function isEmailedNumber(): ?string
{
return $this->emailedNumber;
}
public function setEmailedNumber(?string $emailedNumber): self
{
$this->emailedNumber = $emailedNumber;
return $this;
}
public function __clone()
{
$this->uuid= null;
$this->number = null;
$this->isConform = null;
$this->reasonNotConformity = [];
$this->nonConformityType = null;
$this->errorNumber = null;
$this->errorMessage = null;
$this->emailedNumber = null;
$this->createdAt = null;
$this->updatedAt = null;
}
public function getExternalIdIG(): ?string
{
return $this->externalIdIG;
}
public function setExternalIdIG(?string $externalIdIG): self
{
$this->externalIdIG = $externalIdIG;
return $this;
}
public function getCode(): ?Code
{
return $this->code;
}
public function setCode(?Code $code): self
{
$this->code = $code;
return $this;
}
public function isDraw(): ?bool
{
return $this->draw;
}
public function setDraw(?bool $draw): static
{
$this->draw = $draw;
return $this;
}
public function getEan(): ?Product
{
return $this->ean;
}
public function setEan(?Product $ean): static
{
$this->ean = $ean;
return $this;
}
/**
* @return Collection<int, Stock>
*/
public function getStocks(): Collection
{
return $this->stocks;
}
public function addStock(Stock $stock): static
{
if (!$this->stocks->contains($stock)) {
$this->stocks->add($stock);
}
return $this;
}
public function removeStock(Stock $stock): static
{
$this->stocks->removeElement($stock);
return $this;
}
}