src/Entity/Channel/PositioningTest/Attempt/Attempt.php line 26

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Channel\PositioningTest\Attempt;
  3. use App\Entity\Channel\ChannelContact;
  4. use App\Entity\Channel\PositioningTest\PositioningTest;
  5. use App\Entity\ChannelUserData\ChannelUserData;
  6. use App\Entity\Common\Contact;
  7. use App\Enum\Channel\PositioningTest\StatusEnum;
  8. use App\Repository\Channel\PositioningTest\Attempt\AttemptRepository;
  9. use DateTime;
  10. use Doctrine\Common\Collections\ArrayCollection;
  11. use Doctrine\Common\Collections\Collection;
  12. use Doctrine\ORM\Mapping as ORM;
  13. use DrosalysWeb\ObjectExtensions\Blame\Model\BlameInterface;
  14. use DrosalysWeb\ObjectExtensions\Blame\Model\BlameTrait;
  15. use DrosalysWeb\ObjectExtensions\Timestamp\Model\TimestampInterface;
  16. use DrosalysWeb\ObjectExtensions\Timestamp\Model\TimestampTrait;
  17. use Nellapp\Bundle\SDKBundle\Google\Entity\GoogleExportableInterface;
  18. use Nellapp\Bundle\SDKBundle\Google\Entity\GoogleExportedData\GoogleExportedData;
  19. #[
  20.     ORM\Entity(repositoryClassAttemptRepository::class),
  21.     ORM\Table(name'channel_positioning_test_attempts'),
  22. ]
  23. class Attempt implements TimestampInterfaceBlameInterfaceGoogleExportableInterface
  24. {
  25.     use TimestampTrait;
  26.     use BlameTrait;
  27.     #[ORM\Id]
  28.     #[ORM\GeneratedValue]
  29.     #[ORM\Column(type'integer')]
  30.     private ?int $id null;
  31.     #[ORM\Column(type'string'length64uniquetrue)]
  32.     private ?string $accessToken;
  33.     #[ORM\Column(type'datetime'nullabletrue)]
  34.     private ?DateTime $startedAt null;
  35.     #[ORM\Column(type'datetime'nullabletrue)]
  36.     private ?DateTime $endedAt null;
  37.     #[ORM\Column(type'integer')]
  38.     private ?int $time 0;
  39.     #[ORM\Column(type'string'nullabletrueoptions: ['default' => StatusEnum::WAITING])]
  40.     private ?string $status StatusEnum::WAITING;
  41.     #[ORM\Column(type'string'nullabletrueoptions: ['default' => null])]
  42.     private ?string $result null;
  43.     #[ORM\Column(type'boolean'nullablefalse)]
  44.     private bool $emailConfirmed false;
  45.     #[ORM\Column(type'boolean'nullabletrue)]
  46.     private ?bool $isInterestedInWorkStudy null;
  47.     #[ORM\Column(type'boolean'nullabletrue)]
  48.     private ?bool $isInterestedByFindWorkStudyTrainee null;
  49.     // TODO: remove after channel_contact migration validated in prod
  50.     #[ORM\ManyToOne(targetEntityContact::class, cascade: ['persist'])]
  51.     #[ORM\JoinColumn(nullablefalseonDelete'CASCADE')]
  52.     private ?Contact $prospect null;
  53.     #[ORM\ManyToOne(targetEntityChannelContact::class, cascade: ['persist'])]
  54.     #[ORM\JoinColumn(nullabletrueonDelete'SET NULL')]
  55.     private ?ChannelContact $channelContact null;
  56.     #[ORM\ManyToOne(targetEntityChannelUserData::class, cascade: ['persist'], inversedBy:  'positioningTestAttempts')]
  57.     #[ORM\JoinColumn(nullabletrueonDelete'SET NULL')]
  58.     private ?ChannelUserData $channelUserData null;
  59.     #[ORM\ManyToOne(targetEntityPositioningTest::class, inversedBy'attempts')]
  60.     #[ORM\JoinColumn(nullabletrueonDelete'SET NULL')]
  61.     private ?PositioningTest $positioningTest null;
  62.     #[ORM\OneToMany(mappedBy'attempt'targetEntityAttemptBlock::class, cascade: ['persist''remove'], orphanRemovaltrue)]
  63.     #[ORM\OrderBy(['rank' => 'ASC'])]
  64.     private ?Collection $attemptBlocks;
  65.     #[ORM\OneToOne(targetEntityGoogleExportedData::class, cascade: ['persist''remove'], orphanRemovaltrue)]
  66.     #[ORM\JoinColumn(nullabletrueonDelete'SET NULL')]
  67.     private ?GoogleExportedData $googleExportedData null;
  68.     public function __construct()
  69.     {
  70.         $this->accessToken bin2hex(random_bytes(32));
  71.         $this->attemptBlocks = new ArrayCollection();
  72.     }
  73.     public function getId(): ?int
  74.     {
  75.         return $this->id;
  76.     }
  77.     public function getAccessToken(): ?string
  78.     {
  79.         return $this->accessToken;
  80.     }
  81.     public function setAccessToken(?string $accessToken): static
  82.     {
  83.         $this->accessToken $accessToken;
  84.         return $this;
  85.     }
  86.     public function getStartedAt(): ?DateTime
  87.     {
  88.         return $this->startedAt;
  89.     }
  90.     public function setStartedAt(?DateTime $startedAt): static
  91.     {
  92.         $this->startedAt $startedAt;
  93.         return $this;
  94.     }
  95.     public function getEndedAt(): ?DateTime
  96.     {
  97.         return $this->endedAt;
  98.     }
  99.     public function setEndedAt(?DateTime $endedAt): static
  100.     {
  101.         $this->endedAt $endedAt;
  102.         return $this;
  103.     }
  104.     public function getTime(): ?int
  105.     {
  106.         return $this->time;
  107.     }
  108.     public function setTime(?int $time): static
  109.     {
  110.         $this->time $time;
  111.         return $this;
  112.     }
  113.     public function getStatus(): ?string
  114.     {
  115.         return $this->status;
  116.     }
  117.     public function setStatus(?string $status): static
  118.     {
  119.         $this->status $status;
  120.         return $this;
  121.     }
  122.     public function getResult(): ?string
  123.     {
  124.         return $this->result;
  125.     }
  126.     public function setResult(?string $result): static
  127.     {
  128.         $this->result $result;
  129.         return $this;
  130.     }
  131.     public function isEmailConfirmed(): bool
  132.     {
  133.         return $this->emailConfirmed;
  134.     }
  135.     public function setEmailConfirmed(bool $emailConfirmed): static
  136.     {
  137.         $this->emailConfirmed $emailConfirmed;
  138.         return $this;
  139.     }
  140.     public function getIsInterestedInWorkStudy(): ?bool
  141.     {
  142.         return $this->isInterestedInWorkStudy;
  143.     }
  144.     public function setIsInterestedInWorkStudy(?bool $isInterestedInWorkStudy): static
  145.     {
  146.         $this->isInterestedInWorkStudy $isInterestedInWorkStudy;
  147.         return $this;
  148.     }
  149.     public function getIsInterestedByFindWorkStudyTrainee(): ?bool
  150.     {
  151.         return $this->isInterestedByFindWorkStudyTrainee;
  152.     }
  153.     public function setIsInterestedByFindWorkStudyTrainee(?bool $isInterestedByFindWorkStudyTrainee): static
  154.     {
  155.         $this->isInterestedByFindWorkStudyTrainee $isInterestedByFindWorkStudyTrainee;
  156.         return $this;
  157.     }
  158.     public function getOldProspect(): ?Contact
  159.     {
  160.         // TODO: remove after channel_contact migration validated in prod
  161.         return $this->prospect;
  162.     }
  163.     public function setProspect(?Contact $prospect): static
  164.     {
  165.         // TODO: remove after channel_contact migration validated in prod
  166.         $this->prospect $prospect;
  167.         return $this;
  168.     }
  169.     public function getProspect(): ?Contact
  170.     {
  171.         return $this->getChannelContact()?->getContact();
  172.     }
  173.     public function getChannelContact(): ?ChannelContact
  174.     {
  175.         return $this->channelContact;
  176.     }
  177.     public function setChannelContact(?ChannelContact $channelContact): static
  178.     {
  179.         $this->channelContact $channelContact;
  180.         $this->setProspect($channelContact->getContact());
  181.         return $this;
  182.     }
  183.     public function getChannelUserData(): ?ChannelUserData
  184.     {
  185.         return $this->channelUserData;
  186.     }
  187.     public function setChannelUserData(?ChannelUserData $channelUserData): static
  188.     {
  189.         $this->channelUserData $channelUserData;
  190.         return $this;
  191.     }
  192.     public function getPositioningTest(): ?PositioningTest
  193.     {
  194.         return $this->positioningTest;
  195.     }
  196.     public function setPositioningTest(?PositioningTest $positioningTest): static
  197.     {
  198.         $this->positioningTest $positioningTest;
  199.         return $this;
  200.     }
  201.     /**
  202.      * @return Collection<int, AttemptBlock>|null
  203.      */
  204.     public function getAttemptBlocks(): ?Collection
  205.     {
  206.         return $this->attemptBlocks;
  207.     }
  208.     public function addAttemptBlock(AttemptBlock $attemptBlock): self
  209.     {
  210.         if (!$this->attemptBlocks->contains($attemptBlock)) {
  211.             $attemptBlock->setAttempt($this);
  212.             $this->attemptBlocks[] = $attemptBlock;
  213.         }
  214.         return $this;
  215.     }
  216.     public function removeAttemptBlock(AttemptBlock $attemptBlock): self
  217.     {
  218.         if ($this->attemptBlocks->contains($attemptBlock)) {
  219.             $this->attemptBlocks->removeElement($attemptBlock);
  220.         }
  221.         return $this;
  222.     }
  223.     public function getGoogleExportedData(): ?GoogleExportedData
  224.     {
  225.         return $this->googleExportedData;
  226.     }
  227.     public function setGoogleExportedData(?GoogleExportedData $googleExportedData): static
  228.     {
  229.         $this->googleExportedData $googleExportedData;
  230.         return $this;
  231.     }
  232. }