src/Entity/TelegramCampaignParticipant.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Enum\TelegramCampaignParticipant\SendStatus;
  4. use App\Repository\TelegramCampaignParticipantRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7.  * @ORM\Entity(repositoryClass=TelegramCampaignParticipantRepository::class)
  8.  */
  9. class TelegramCampaignParticipant
  10. {
  11.     /**
  12.      * @ORM\Id
  13.      * @ORM\GeneratedValue
  14.      * @ORM\Column(type="integer")
  15.      */
  16.     private $id;
  17.     /**
  18.      * @ORM\ManyToOne(targetEntity=Candidate::class)
  19.      */
  20.     private $candidate;
  21.     /**
  22.      * @ORM\ManyToOne(targetEntity=TelegramCampaign::class, inversedBy="participants")
  23.      */
  24.     private $telegramCampaign;
  25.     /**
  26.      * @ORM\Column(type="enum", options={"values": "telegram_campaign_participant_enum"})
  27.      */
  28.     private $sendStatus SendStatus::SEND_STATUS_NOT_SENT;
  29.     /**
  30.      * @ORM\Column(type="datetime")
  31.      */
  32.     private $createdAt;
  33.     /**
  34.      * @ORM\Column(type="text", nullable=true)
  35.      */
  36.     private $responseData;
  37.     /**
  38.      * @ORM\Column(type="datetime", nullable=true)
  39.      */
  40.     private $sentAt;
  41.     public function __construct()
  42.     {
  43.         $this->createdAt = new \DateTime();
  44.     }
  45.     public function getId(): ?int
  46.     {
  47.         return $this->id;
  48.     }
  49.     public function getCandidate(): ?Candidate
  50.     {
  51.         return $this->candidate;
  52.     }
  53.     public function setCandidate(?Candidate $candidate): self
  54.     {
  55.         $this->candidate $candidate;
  56.         return $this;
  57.     }
  58.     public function getTelegramCampaign(): ?TelegramCampaign
  59.     {
  60.         return $this->telegramCampaign;
  61.     }
  62.     public function setTelegramCampaign(?TelegramCampaign $telegramCampaign): self
  63.     {
  64.         $this->telegramCampaign $telegramCampaign;
  65.         return $this;
  66.     }
  67.     public function getSendStatus()
  68.     {
  69.         return $this->sendStatus;
  70.     }
  71.     public function isSendStatusCanceled(): bool
  72.     {
  73.         return $this->getSendStatus() === SendStatus::SEND_STATUS_CANCELED;
  74.     }
  75.     public function isSendStatusNotSent(): bool
  76.     {
  77.         return $this->getSendStatus() === SendStatus::SEND_STATUS_NOT_SENT;
  78.     }
  79.     public function canRemoveFromCampaign(): bool
  80.     {
  81.         return in_array($this->getSendStatus(), SendStatus::getCampaignRemovableStatuses());
  82.     }
  83.     public function canCancelFromCampaign(): bool
  84.     {
  85.         return in_array($this->getSendStatus(), SendStatus::getCampaignCancelableStatuses());
  86.     }
  87.     public function getSendStatusText(): string
  88.     {
  89.         return SendStatus::getText($this->sendStatus);
  90.     }
  91.     public function setSendStatus($sendStatus): self
  92.     {
  93.         $this->sendStatus $sendStatus;
  94.         if ($sendStatus === SendStatus::SEND_STATUS_SENT) {
  95.             $this->setSentAt(new \DateTime());
  96.         }
  97.         return $this;
  98.     }
  99.     public function getCreatedAt(): ?\DateTimeInterface
  100.     {
  101.         return $this->createdAt;
  102.     }
  103.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  104.     {
  105.         $this->createdAt $createdAt;
  106.         return $this;
  107.     }
  108.     public function getSendStatusCssClass($prefix null): string
  109.     {
  110.         return SendStatus::getCssClass($this->sendStatus$prefix);
  111.     }
  112.     public function getResponseData(): ?array
  113.     {
  114.         return json_decode($this->responseData ?? "{}"true);
  115.     }
  116.     public function setResponseData(?array $responseData): self
  117.     {
  118.         $this->responseData json_encode($responseData,
  119.             JSON_UNESCAPED_SLASHES JSON_UNESCAPED_UNICODE);
  120.         return $this;
  121.     }
  122.     public function appendResponseDataItem(array $responseDataItem): self
  123.     {
  124.         $allData $this->getResponseData() ?? [];
  125.         $allData[] = $responseDataItem;
  126.         $this->setResponseData($allData);
  127.         return $this;
  128.     }
  129.     public function setResponseDataItem(array $responseDataItemint $key): self
  130.     {
  131.         $allData $this->getResponseData() ?? [];
  132.         $allData[$key] = $responseDataItem;
  133.         $this->setResponseData($allData);
  134.         return $this;
  135.     }
  136.     public function getSentAt(): ?\DateTimeInterface
  137.     {
  138.         return $this->sentAt;
  139.     }
  140.     public function setSentAt(?\DateTimeInterface $sentAt): self
  141.     {
  142.         $this->sentAt $sentAt;
  143.         return $this;
  144.     }
  145. }