src/Entity/Participation/Participation.php line 30

  1. <?php
  2. namespace App\Entity\Participation;
  3. use App\Entity\Code;
  4. use App\Entity\Product;
  5. use App\Entity\Stock;
  6. use App\Entity\Traits\TimestampableTrait;
  7. use App\Entity\User;
  8. use App\Repository\Participation\ParticipationRepository;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\Common\Collections\Collection;
  11. use Doctrine\DBAL\Types\Types;
  12. use Doctrine\ORM\Mapping as ORM;
  13. use Symfony\Component\Serializer\Annotation\Groups;
  14. use Symfony\Component\Serializer\Annotation\SerializedName;
  15. use Ramsey\Uuid\Doctrine\UuidGenerator;
  16. use Ramsey\Uuid\UuidInterface as Uuid;
  17. use Symfony\Component\Validator\Constraints as Assert;
  18. #[ORM\Entity(repositoryClassParticipationRepository::class)]
  19. #[ORM\InheritanceType('SINGLE_TABLE')]
  20. #[ORM\DiscriminatorColumn(name'discr'type'string')]
  21. #[ORM\DiscriminatorMap([
  22.     'odr' => 'Odr',
  23.     'ig' => 'Ig',
  24.     'asso' => 'Asso',
  25.     'draw' => 'Draw'
  26. ])]
  27. class Participation
  28. {
  29.     use TimestampableTrait;
  30.     public const API_SOGEC_ACTION 'create';
  31.     public const API_SOGEC_CHANNEL 'FW';
  32.     public const PARTICIPATION_DISCR_ODR 'odr';
  33.     public const PARTICIPATION_DISCR_IG 'ig';
  34.     public const PARTICIPATION_DISCR_ASSO 'asso';
  35.     public const PARTICIPATION_DISCR_DRAW 'draw';
  36.     public const ARRAY_PARTICIPATION_DISCR = [
  37.         self::PARTICIPATION_DISCR_ODR,
  38.         self::PARTICIPATION_DISCR_IG,
  39.         self::PARTICIPATION_DISCR_ASSO,
  40.         self::PARTICIPATION_DISCR_DRAW
  41.     ];
  42.     #[ORM\Id]
  43.     #[ORM\Column(type"uuid"uniquetrue)]
  44.     #[ORM\GeneratedValue(strategy'CUSTOM')]
  45.     #[ORM\CustomIdGenerator(class: UuidGenerator::class)]
  46.     #[Assert\Uuid]
  47.     #[SerializedName('participation_id')]
  48.     #[Groups(['global'])]
  49.     private ?Uuid $uuid null;
  50.     #[ORM\Column(length13uniquetruenullabletrue)]
  51.     private ?string $number null;
  52.     #[ORM\Column(typeTypes::BOOLEANnullabletrue)]
  53.     private ?bool $isConform null;
  54.     #[ORM\Column(typeTypes::JSONnullabletrue)]
  55.     private array $reasonNotConformity = [];
  56.     #[ORM\Column(length10nullabletrue)]
  57.     private ?string $nonConformityType null;
  58.     #[ORM\ManyToOne(cascade: ["persist"], inversedBy'participations')]
  59.     private ?User $user null;
  60.     #[ORM\Column(typeTypes::BOOLEANnullabletrue)]
  61.     private ?bool $confirmed null;
  62.     #[ORM\Column(nullabletrue)]
  63.     private ?int $errorNumber null;
  64.     #[ORM\Column(length255nullabletrue)]
  65.     private ?string $errorMessage null;
  66.     #[ORM\Column(length50nullabletrue)]
  67.     private ?string $emailedNumber null;
  68.     #[ORM\OneToOne(targetEntityCode::class)]
  69.     #[ORM\JoinColumn(referencedColumnName'id')]
  70.     private ?Code $code null;
  71.     //instant gagnant's id from api-instant-gagnant
  72.     #[ORM\Column(length100nullabletrue)]
  73.     private ?string $externalIdIG null;
  74.     #[ORM\Column(nullabletrue)]
  75.     private ?bool $draw null;
  76.     #[ORM\ManyToOne(inversedBy'participations')]
  77.     private ?Product $ean null;
  78.     #[ORM\ManyToMany(targetEntityStock::class, inversedBy'participations')]
  79.     #[ORM\JoinColumn(name"participation_uuid"referencedColumnName"uuid")]
  80.     private Collection $stocks;
  81.     public function __construct()
  82.     {
  83.         $this->stocks = new ArrayCollection();
  84.     }
  85.     #[SerializedName('date_participation')]
  86.     #[Groups(['global'])]
  87.     public function getParticipationDate(): string
  88.     {
  89.         return $this->createdAt->format("Y-m-d H:i:s");
  90.     }
  91.     #[SerializedName('code_promo')]
  92.     #[Groups(['global'])]
  93.     public function getCodePromo(): ?string
  94.     {
  95.         return $this->code?->getCode();
  96.     }
  97.     public function insertConstantValues(object $obj): object
  98.     {
  99.         $obj->action self::API_SOGEC_ACTION;
  100.         $obj->channel = (in_array($this->code->getPalier(), ['PAL03''PAL04'])) ? 'FI' self::API_SOGEC_CHANNEL;
  101.         return $obj;
  102.     }
  103.     public function getUuid(): ?Uuid
  104.     {
  105.         return $this->uuid;
  106.     }
  107.     public function getNumber(): ?string
  108.     {
  109.         return $this->number;
  110.     }
  111.     public function setNumber(?string $number): self
  112.     {
  113.         $this->number $number;
  114.         return $this;
  115.     }
  116.     public function isIsConform(): ?bool
  117.     {
  118.         return $this->isConform;
  119.     }
  120.     public function setIsConform(?bool $isConform): self
  121.     {
  122.         $this->isConform $isConform;
  123.         return $this;
  124.     }
  125.     public function getReasonNotConformity(): array
  126.     {
  127.         return $this->reasonNotConformity;
  128.     }
  129.     public function setReasonNotConformity(?array $reasonNotConformity): self
  130.     {
  131.         $this->reasonNotConformity $reasonNotConformity;
  132.         return $this;
  133.     }
  134.     public function getNonConformityType(): ?string
  135.     {
  136.         return $this->nonConformityType;
  137.     }
  138.     public function setNonConformityType(?string $nonConformityType): self
  139.     {
  140.         $this->nonConformityType $nonConformityType;
  141.         return $this;
  142.     }
  143.     public function getUser(): ?User
  144.     {
  145.         return $this->user;
  146.     }
  147.     public function setUser(?User $user): self
  148.     {
  149.         $this->user $user;
  150.         return $this;
  151.     }
  152.     public function isConfirmed(): ?bool
  153.     {
  154.         return $this->confirmed;
  155.     }
  156.     public function setConfirmed(?bool $confirmed): self
  157.     {
  158.         $this->confirmed $confirmed;
  159.         return $this;
  160.     }
  161.     public function getErrorNumber(): ?int
  162.     {
  163.         return $this->errorNumber;
  164.     }
  165.     public function setErrorNumber(?int $errorNumber): self
  166.     {
  167.         $this->errorNumber $errorNumber;
  168.         return $this;
  169.     }
  170.     public function getErrorMessage(): ?string
  171.     {
  172.         return $this->errorMessage;
  173.     }
  174.     public function setErrorMessage(?string $errorMessage): self
  175.     {
  176.         $this->errorMessage $errorMessage;
  177.         return $this;
  178.     }
  179.     public function isEmailedNumber(): ?string
  180.     {
  181.         return $this->emailedNumber;
  182.     }
  183.     public function setEmailedNumber(?string $emailedNumber): self
  184.     {
  185.         $this->emailedNumber $emailedNumber;
  186.         return $this;
  187.     }
  188.     public function __clone()
  189.     {
  190.         $this->uuidnull;
  191.         $this->number null;
  192.         $this->isConform null;
  193.         $this->reasonNotConformity = [];
  194.         $this->nonConformityType null;
  195.         $this->errorNumber null;
  196.         $this->errorMessage null;
  197.         $this->emailedNumber null;
  198.         $this->createdAt null;
  199.         $this->updatedAt null;
  200.     }
  201.     public function getExternalIdIG(): ?string
  202.     {
  203.         return $this->externalIdIG;
  204.     }
  205.     public function setExternalIdIG(?string $externalIdIG): self
  206.     {
  207.         $this->externalIdIG $externalIdIG;
  208.         return $this;
  209.     }
  210.     public function getCode(): ?Code
  211.     {
  212.         return $this->code;
  213.     }
  214.     public function setCode(?Code $code): self
  215.     {
  216.         $this->code $code;
  217.         return $this;
  218.     }
  219.     public function isDraw(): ?bool
  220.     {
  221.         return $this->draw;
  222.     }
  223.     public function setDraw(?bool $draw): static
  224.     {
  225.         $this->draw $draw;
  226.         return $this;
  227.     }
  228.     public function getEan(): ?Product
  229.     {
  230.         return $this->ean;
  231.     }
  232.     public function setEan(?Product $ean): static
  233.     {
  234.         $this->ean $ean;
  235.         return $this;
  236.     }
  237.     /**
  238.      * @return Collection<int, Stock>
  239.      */
  240.     public function getStocks(): Collection
  241.     {
  242.         return $this->stocks;
  243.     }
  244.     public function addStock(Stock $stock): static
  245.     {
  246.         if (!$this->stocks->contains($stock)) {
  247.             $this->stocks->add($stock);
  248.         }
  249.         return $this;
  250.     }
  251.     public function removeStock(Stock $stock): static
  252.     {
  253.         $this->stocks->removeElement($stock);
  254.         return $this;
  255.     }
  256. }